need help! about mysqli 'multi_query' method

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
chrisyue
Forum Newbie
Posts: 1
Joined: Mon Mar 10, 2008 4:36 am

need help! about mysqli 'multi_query' method

Post by chrisyue »

~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.

Code: Select all

 
$sql = 'truncate table `bbs_classes_t`;';
$sql.= 'truncate table `bbs_subjects_t`;';
$sql.= 'truncate table `bbs_replies_t`;';
$sql.= 'truncate table `bbs_forums_t`;';
$sql.= 'truncate table `bbs_admin_assignment_t`;';
$sql.= 'truncate table `bbs_rules_assignment_t`;';
$sql.= 'truncate table `bbs_rules_t`;';
$to->multi_query($sql); //reset tables
 
$result = $from->query('select * from `bbs_class_info`'); //handle `bbs_class_info`
//...some get data and insert data operations
 
i wanna transfer my data from database '$from' to '$to', first i reset tables in $to, use a mysqli method 'multi_query', but it always get an error:Commands out of sync; you can't run this command now when execute one of the INSERT operations

it seems no errors in my code, if is this a bug or not? How can i get rid of this kind of error message?


~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.
www.WeAnswer.IT
Forum Newbie
Posts: 24
Joined: Wed Mar 19, 2008 6:33 pm

Re: need help! about mysqli 'multi_query' method

Post by www.WeAnswer.IT »

Try replacing:

Code: Select all

$to->multi_query($sql); //reset tables
With:

Code: Select all

$to->multi_query($sql); //reset tables
while($to->next_result()) $to->store_result();
I'm not sure that will help, but what it does is clear the resultset buffer.
Post Reply