Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hmmm, so it’s more complicated than this.
    Did you try with newer versions of WordPress, like the 4.1?
    I’ll also have to face this problem at the begin of the year, upgrading our website. By the moment I’m on holidays.

    With some chance, Hawkix will deliver us something functional until there ??

    Unfortunately, PG4WP have to be consider a hack, and not a stable plugin. A little bit like jailbreaks. It won’t provide a 100% compatibility and not necessarily work with all versions. When you find a WordPress version that works well for your needs, keep it. Same for the extensions. PG4WP introduces fragility in updates, as core developers don’t officially support this code. So be aware and always test your updates in a pre-prod environment.

    Disclaimer: I’m not using WordPress 3.9.3 by the moment, this is a theoretical solution based on my lecture of the code and generated error. Use it at your own risk. Use a test setup and test all functions you need before deploying this patch in a production!

    SESSION.sql_mode is a way of getting the settings of MySQL. This won’t work on Postgresql.
    You can try to bypass this check by modifying the file wp-includes/wp-db.php line 737:
    [code] if ( $this->use_mysqli ) {
    $res = mysqli_query( $this->dbh, 'SELECT @@SESSION.sql_mode' );
    } else {
    $res = mysql_query( 'SELECT @@SESSION.sql_mode', $this->dbh );
    }
    [/code]
    Comment this code and change it by $res = “”; as following:
    [code]/* if ( $this->use_mysqli ) {
    $res = mysqli_query( $this->dbh, 'SELECT @@SESSION.sql_mode' );
    } else {
    $res = mysql_query( 'SELECT @@SESSION.sql_mode', $this->dbh );
    }*/
    $res = "";
    [/code]

    Let me know if this solves your problem ??

    Thanks for sharing this hack, falydev, compiled this with another step related to the wpsql_errno in my blog so you normally have all the needed tweaks to make WordPress 3.9.1 work on a Postgresql database.

    I’ve tested installing and creating/modifying content successfully. Be careful to make extended tests if you have extensions (that I don’t use).

    I’ve also posted this solution at my blog, if you would like to have a look ??
    Have a nice day!

    Alternative solution, create the errno function at the end of wp-content/pg4wp/driver_pgsql.php:

    function wpsql_errno( $connection) {
    		$result = pg_get_result($connection);
    		$result_status = pg_result_status($result);
    		return pg_result_error_field($result_status, PGSQL_DIAG_SQLSTATE);
    	}

    Thread Starter vitorio

    (@vitorio)

    Hi there…

    Using my method is breaking the return ID of INSERT commands. Analyzing the code, I found this portion at the end of pgsql_rewrite not being exactly rewrite code, but a setup of this ID return value for INSERTS:

    // For insert ID catching
    if( 0 === strpos($sql, 'INSERT') )
    {
    	$pattern = '/INSERT INTO (\w+)\s+\([ a-zA-Z_"]+/';
    	preg_match($pattern, $sql, $matches);
    	$GLOBALS['pg4wp_ins_table'] = $matches[1];
    	$match_list = split(' ', $matches[0]);
    	if( $GLOBALS['pg4wp_ins_table'])
    	{
    		$GLOBALS['pg4wp_ins_field'] = trim($match_list[3],' ()	');
    		if(! $GLOBALS['pg4wp_ins_field'])
    			$GLOBALS['pg4wp_ins_field'] = trim($match_list[4],' ()	');
    	}
    	$GLOBALS['pg4wp_last_insert'] = $sql;
    }
    elseif( isset($GLOBALS['pg4wp_queued_query']))
    {
    	pg_query($GLOBALS['pg4wp_queued_query']);
    	unset($GLOBALS['pg4wp_queued_query']);
    }

    I moved it up to the wpsql_query function and am still testing the effects it can have in my code. Found no side effect by now. If a developer of this plugin read this, I would suggest to move it on the official release, as obtaining the return value of an insert have nothing to do with a mysql -> pgsql rewrite. At least for me, it’s seams more logical to find this code on wpsql_query function.

    However, great job with this plugin. Cheers!

    Thread Starter vitorio

    (@vitorio)

    Solved it with conditional comments.
    Hacked the function wpsql_query at line 131 like this:

    if(strpos($sql, '/*+NO_PARSE */') === false)
    			$sql = pg4wp_rewrite( $sql);

    Then I put a /*+NO_PARSE */ in every SQL query I make.

    I’ve got a similar problem -> here
    Your modification didn’t solve it. Your patterns makes WordPress displaying a 404 page instead of my content. Strange.

    Found another solution bypassing the parser for my specific code using:

    if(strpos($sql, '/*+NO_PARSE */') === false)
    			$sql = pg4wp_rewrite( $sql);

    in the wpsql_query function (line 131).
    Then I use this comment on each SQL command I make, as I’m coding native PostGreSQL code.

Viewing 8 replies - 1 through 8 (of 8 total)