mysql id field just submitted
Ok, I find myself doing this often. I'll开发者_如何转开发 attach ids to my tables and I'll "link" the tables together. Just a simple example, a team roster might have categories. Each category has an id. When I add players into the roster, I'll assign them a category id as well to signify that they are part of that category.
My question is, for this example, say I'm creating a category and a player at the same. I submit the category but now I have to get the category id to assign it to the player table row. Any suggestions on how to do this efficiently? Currently I would query the database again, and search for specific data related to the category, which doesn't seem very effective.
Note also, the id's Im using are generated by mysql.
Any suggestions would be helpful!
Check out mysql_insert_id()
精彩评论