Corrections for WP 3.1+ support
git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@418075 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
@@ -45,4 +45,10 @@ $replaces = array(
|
||||
);
|
||||
eval( str_replace( array_keys($replaces), array_values($replaces), file_get_contents(ABSPATH.'/wp-includes/wp-db.php')));
|
||||
require_once( ABSPATH.'/wp-includes/wp-db.php');
|
||||
|
||||
if (! isset($wpdb)) {
|
||||
// Create wpdb object if not already done
|
||||
$wpdb = new wpdb2( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
|
||||
}
|
||||
|
||||
} // Protection against multiple loading
|
@@ -70,14 +70,18 @@
|
||||
$pg_password = $GLOBALS['pg4wp_password'];
|
||||
$pg_server = $GLOBALS['pg4wp_server'];
|
||||
if( empty( $pg_server))
|
||||
$conn = pg_connect("user=$pg_user password=$pg_password dbname=$dbname");
|
||||
$GLOBALS['pg4wp_conn'] = pg_connect("user=$pg_user password=$pg_password dbname=$dbname");
|
||||
else
|
||||
$conn = pg_connect("host=$pg_server user=$pg_user password=$pg_password dbname=$dbname");
|
||||
$GLOBALS['pg4wp_conn'] = pg_connect("host=$pg_server user=$pg_user password=$pg_password dbname=$dbname");
|
||||
// Now we should be connected, we "forget" about the connection parameters
|
||||
$GLOBALS['pg4wp_user'] = '';
|
||||
$GLOBALS['pg4wp_password'] = '';
|
||||
$GLOBALS['pg4wp_server'] = '';
|
||||
return $conn;
|
||||
// Execute early transmitted commands if needed
|
||||
if( isset($GLOBALS['pg4wp_pre_sql']) && !empty($GLOBALS['pg4wp_pre_sql']))
|
||||
foreach( $GLOBALS['pg4wp_pre_sql'] as $sql2run)
|
||||
wpsql_query( $sql2run);
|
||||
return $GLOBALS['pg4wp_conn'];
|
||||
}
|
||||
|
||||
function wpsql_fetch_array($result)
|
||||
@@ -92,6 +96,12 @@
|
||||
|
||||
function wpsql_query($sql)
|
||||
{
|
||||
if( !isset($GLOBALS['pg4wp_conn']))
|
||||
{
|
||||
// Catch SQL to be executed as soon as connected
|
||||
$GLOBALS['pg4wp_pre_sql'][] = $sql;
|
||||
return true;
|
||||
}
|
||||
global $table_prefix;
|
||||
$logto = 'queries';
|
||||
// This is used to catch the number of rows returned by the last "SELECT" REQUEST
|
||||
|
Reference in New Issue
Block a user