katarra Posted March 4, 2010 Share Posted March 4, 2010 I had someone tell me that this will solve a problem I have, but I'm not quite sure what it means and I haven't gotten a response for a few days now. Can anyone provide an example or point me to an example? Thanks! You'll need to send a separate query for each field. So if you're making an item with fields for "name", "type", "slot", and "attack power", you'll need to send four insert commands to the database. Link to comment https://forums.phpfreaks.com/topic/194189-php-coding-for-separate-queries-question/ Share on other sites More sharing options...
veridicus Posted March 4, 2010 Share Posted March 4, 2010 Some context would help... Link to comment https://forums.phpfreaks.com/topic/194189-php-coding-for-separate-queries-question/#findComment-1021701 Share on other sites More sharing options...
katarra Posted March 4, 2010 Author Share Posted March 4, 2010 I have a database field setup that has 3 columns: id, field, value I'm wanting to use this as an item inventory repository, so that the information can be pulled when needed later in the program. But, for now, I want to create the items to go into it, but each item will have multiple fields and multiple values but only a single unique id spread across a few rows. For instance, take: 1 weapon Sword 1 attackpower 5 1 cost 100 Something simple like that. Link to comment https://forums.phpfreaks.com/topic/194189-php-coding-for-separate-queries-question/#findComment-1021705 Share on other sites More sharing options...
veridicus Posted March 4, 2010 Share Posted March 4, 2010 Well, first you'll have to get a unique ID since you're using it across multiple rows. One option is to lock the table, then query for max(id) + 1. Then you'll need a multi-line insert statement, or multiple single line insert statements. In mysql, you can INSERT INTO tablename (id, field, value) VALUES (1, 'weapon', 'sword'), (1, 'attackpower', '5'), (1, 'cost', '100'); Then unlock the table. Link to comment https://forums.phpfreaks.com/topic/194189-php-coding-for-separate-queries-question/#findComment-1021711 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.