3

Just bump into the issue that I can't execute multiple sql queries using the $wpdb->query(). Generated queries work fine directly in phpmyadmin so its something will the ezSQL class only. By design perhaps?

I found this http://wordpress.org/support/topic/wpdb-gtquery-fails-when-multiple-update-statements-are-used which also says its by design. Can anyone confirm? ezSQL docs dont say anything about multiple queries support.

If you have to do a bunch of queries mainly (INSERT/UPDATE/DELETE), any better way of doing them other than doing them one by one using $wpdb->insert() and like functions?

2
  • Interesting question, can you edit it and include a code example? This will teach more users about multiple statements in one query. Does it help to use transactions here? Commented Apr 26, 2011 at 7:04
  • What's the issue with doing them one by one? Commented Mar 6, 2012 at 15:46

1 Answer 1

0

Using PHP 5.3.5, I was unable to make this syntax work even after setting the 5th parameter of mysql_connect() to 65536 (CLIENT_MULTI_STATEMENTS). Looks like it's not possible to concatenate multiple queries into one statement as long as the old-school MySQL API is running the show.

I assume you're familiar with the MySQL multiple row INSERT syntax, but I mention it just in case.

1
  • Thanks for checking, looks like its mysql's fault then and not of ezSQL. Yes, I am using multiple row syntax for inserts now. I will just wait for sometime in case someone stops by and add something here before accepting your answer. Commented Apr 25, 2011 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.