Correct SQL_CALC_FOUND_ROWS handling as it was broken by the latest code reorganisation

git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@436152 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
hawk__
2011-09-11 00:00:04 +00:00
parent a9d154b1b4
commit c89f560605
2 changed files with 8 additions and 11 deletions

View File

@ -129,12 +129,6 @@
if( false === strpos($err, 'relation "'.$wpdb->options.'"'))
error_log("Error running :\n$initial\n---- converted to ----\n$sql\n----\n$err\n---------------------\n", 3, PG4WP_LOG.'pg4wp_errors.log');
if( $catchnumrows && $GLOBALS['pg4wp_result'] !== false)
{
$GLOBALS['pg4wp_numrows_query'] = $sql;
if( PG4WP_DEBUG)
error_log( "Number of rows required for :\n$sql\n---------------------\n", 3, PG4WP_LOG.'pg4wp_NUMROWS.log');
}
return $GLOBALS['pg4wp_result'];
}
@ -166,8 +160,6 @@
global $wpdb;
$logto = 'queries';
// This is used to catch the number of rows returned by the last "SELECT" REQUEST
$catchnumrows = false;
// The end of the query may be protected against changes
$end = '';
@ -180,12 +172,14 @@
// SQL_CALC_FOUND_ROWS doesn't exist in PostgreSQL but it's needed for correct paging
if( false !== strpos($sql, 'SQL_CALC_FOUND_ROWS'))
{
$catchnumrows = true;
$sql = str_replace('SQL_CALC_FOUND_ROWS', '', $sql);
$GLOBALS['pg4wp_numrows_query'] = $sql;
if( PG4WP_DEBUG)
error_log( "Number of rows required for :\n$sql\n---------------------\n", 3, PG4WP_LOG.'pg4wp_NUMROWS.log');
}
elseif( false !== strpos($sql, 'FOUND_ROWS()'))
{
// Here we need to convert the latest query into a COUNT query
// Here we convert the latest query into a COUNT query
$sql = $GLOBALS['pg4wp_numrows_query'];
// Remove any LIMIT ... clause (this is the blocking part)
$pattern = '/\s+LIMIT.+/';

View File

@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
Tags: database, postgresql, PostgreSQL, postgres, mysql
Requires at least: 2.5.1
Tested up to: 3.2.1
Stable tag: 1.2.1
Stable tag: 1.2.2
PostgreSQL for WordPress is a special 'plugin' enabling WordPress to be used with a PostgreSQL database.
@ -43,6 +43,9 @@ There is no screenshot for this plugin
== Changelog ==
= 1.2.2 =
* Corrected SQL_CALC_FOUND_ROWS handling, was broken by the latest code reorganisation
= 1.2.1 =
* Corrected 'ON DUPLICATE KEY ...' handling (was not working at all)
* Modified SQL_CALC_FOUND_ROWS handling for correct paging