Resolving table_name from query broken in select query
-
I am using sophisticated code that selects specific database + server depending on the table name the query is coming from (using hyperdb – scaling & performance reasons).
When I used your plugin it didn’t work because your query is badly formatted. WordPress regepx to get table_name from your query isn’t working. I had to modify your code from:
$sql = $wpdb->prepare( "SELECT<code>ID</code>FROM<code>{$wpdb->posts}</code>"."WHERE("."((<code>post_date</code>>0)&&(<code>post_date</code><=%s))OR"."((<code>post_date_gmt</code>>0)&&(<code>post_date_gmt</code><=%s))".")AND<code>post_status</code>='future'LIMIT 10", current_time( 'mysql' ), current_time( 'mysql', 1 ) );
to
$qry = <<<SQL SELECT <code>ID</code> FROM <code>{$wpdb->posts}</code> WHERE ( ( <code>post_date</code> > 0 && <code>post_date</code> <= %s ) OR ( <code>post_date_gmt</code> > 0 && <code>post_date_gmt</code> <= %s ) ) AND <code>post_status</code> = 'future' LIMIT 10 SQL; $sql = $wpdb->prepare($qry, current_time('mysql'), current_time('mysql', 1) );
(with hyperdb)
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Resolving table_name from query broken in select query’ is closed to new replies.