[wp-hackers] wpdb->query and running 2 sql statements with one go
J.D. Grimes
jdg at codesymphony.co
Tue Jul 15 18:31:54 UTC 2014
wpdb uses mysqli_query() - https://core.trac.wordpress.org/browser/tags/3.9.1/src/wp-includes/wp-db.php#L1616
mysqli_multi_query() must be used to run multiple statements - http://php.net/manual/en/mysqli.quickstart.multiple-statement.php
-J.D.
On Jul 15, 2014, at 2:14 PM, Haluk Karamete <halukkaramete at gmail.com> wrote:
> I'd like to be able to run this SQL using one wpdb->query call.
>
> $sql = 'TRUNCATE TABLE `my_new_table` ;ALTER TABLE `my_new_table`
> auto_increment = 1';
>
> $query_result = $wpdb->query($sql);
>
>
> As of 3.9.1, we do have the mysqli support. So, I'm not sure why this would
> not fly.
>
> Is that one of my brain-freeze moments again?
>
>
> but I'm getting the *familiar error: *
>
> You have an error in your SQL syntax; check the manual that corresponds to
> your MySQL server version for the right syntax to use near 'ALTER TABLE
> `my_new_table` auto_increment = 1)' at line 1]
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
More information about the wp-hackers
mailing list