From 5aad8c1dd7fc9104a01db5d897e02a097ec4250e Mon Sep 17 00:00:00 2001 From: hawk__ Date: Wed, 6 Jan 2010 22:50:15 +0000 Subject: [PATCH] Reorganized directory structure Added support for unix socket connections Updated installation guide to reflect directory structure changes Fixed a typo with zdMultiLang support git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@190706 b8457f37-d9ea-0310-8a92-e5e31aec5664 --- db.php => pg4wp/db.php | 12 ++++++++++-- pg4wp/driver_pgsql.php | 9 ++++++--- readme.txt | 28 +++++++++++++--------------- 3 files changed, 29 insertions(+), 20 deletions(-) rename db.php => pg4wp/db.php (64%) diff --git a/db.php b/pg4wp/db.php similarity index 64% rename from db.php rename to pg4wp/db.php index 7e2733b..b028c83 100644 --- a/db.php +++ b/pg4wp/db.php @@ -8,13 +8,21 @@ // You can choose the driver to load here define('DB_DRIVER', 'pgsql'); // 'pgsql' or 'mysql' are supported for now +// This defines the directory where PG4WP files are +define( 'PG4WP_ROOT', dirname( __FILE__).'/plugins/pg4wp'); + // Set this to 'true' and check that `pg4wp` is writable if you want debug logs to be written define( 'PG4WP_DEBUG', false); // Logs are put in the pg4wp directory -define( 'PG4WP_LOG', dirname( __FILE__).'/pg4wp/'); +define( 'PG4WP_LOG', PG4WP_ROOT.'/logs/'); +// Check if the logs directory is needed and exists or create it if possible +if( PG4WP_DEBUG && + !file_exists( PG4WP_LOG) && + is_writable(dirname( PG4WP_LOG))) + mkdir( PG4WP_LOG); // Load the driver defined above -require_once( dirname( __FILE__).'/pg4wp/driver_'.DB_DRIVER.'.php'); +require_once( PG4WP_ROOT.'/driver_'.DB_DRIVER.'.php'); // This loads up the wpdb class applying the appropriate changes to it, DON'T TOUCH ! $replaces = array( diff --git a/pg4wp/driver_pgsql.php b/pg4wp/driver_pgsql.php index ec2bff4..50855dc 100644 --- a/pg4wp/driver_pgsql.php +++ b/pg4wp/driver_pgsql.php @@ -71,7 +71,7 @@ { if( $GLOBALS['pg4wp_user'] == '') return pg_last_error(); else return ''; } function wpsql_fetch_assoc($result) { return pg_fetch_assoc($result); } function wpsql_escape_string($s) { return pg_escape_string($s); } - function wpsql_get_server_info() { return '4.1.0'; } // Just want to fool wordpress ... + function wpsql_get_server_info() { return '4.1.3'; } // Just want to fool wordpress ... function wpsql_result($result, $i, $fieldname) { return pg_fetch_result($result, $i, $fieldname); } @@ -89,7 +89,10 @@ $pg_user = $GLOBALS['pg4wp_user']; $pg_password = $GLOBALS['pg4wp_password']; $pg_server = $GLOBALS['pg4wp_server']; - $conn = pg_connect("host=$pg_server user=$pg_user password=$pg_password dbname=$dbname"); + if( empty( $pg_server)) + $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"); // Now we should be connected, we "forget" about the connection parameters $GLOBALS['pg4wp_user'] = ''; $GLOBALS['pg4wp_password'] = ''; @@ -223,7 +226,7 @@ if( $GLOBALS['pg4wp_ins_table'] == $table_prefix.'zd_ml_trans') { preg_match( '/VALUES \([^\d]*(\d+)', $sql, $matches); - $GLOBALS['pg4wp_insid'] = $match[1]; + $GLOBALS['pg4wp_insid'] = $matches[1]; } // Fix inserts into wp_categories diff --git a/readme.txt b/readme.txt index f96b407..0f45119 100644 --- a/readme.txt +++ b/readme.txt @@ -3,8 +3,8 @@ Contributors: Hawk__ (http://www.hawkix.net/) Donate link: http://www.hawkix.net/faire-un-don/ Tags: database, postgresql, PostgreSQL, postgres, mysql Requires at least: 2.5.1 -Tested up to: 2.8.2 -Stable tag: 1.0.0 +Tested up to: 2.8.6 +Stable tag: 1.0.1 PostgreSQL for WordPress is a special 'plugin' enabling WordPress to be used with a PostgreSQL database. @@ -12,7 +12,7 @@ PostgreSQL for WordPress is a special 'plugin' enabling WordPress to be used wit Wordpress has always been locked into using mysql as its database storage engine. There is a good discussion of 'why' [in the codex](http://codex.wordpress.org/Using_Alternative_Databases#Solutions/ "Codex Discussion") -But some people would like to use some other databases such as PostgreSQL. There are many diffrent motivations behind this, sometimes people already have PostgreSQL on their server and don't want to install MySQL along PostgreSQL, or simply don't like MySQL and prefer using alternatives. +But some people would like to use some other databases such as PostgreSQL. There are many different motivations behind this, sometimes people already have PostgreSQL on their server and don't want to install MySQL along PostgreSQL, or simply don't like MySQL and prefer using alternatives. PostgreSQL for WordPress (PG4WP) gives you the possibility tu install and use WordPress with a PostgreSQL database as a backend. It works by replacing calls to MySQL specific functions with generic calls that maps them to another database functions. @@ -31,20 +31,11 @@ You have to install it before setting up your WordPress installation for things This section describes how to install the plugin and get it working. This is because the database needs to be up and running before any plugin can be loaded. -1. Unzip the files in your `/wp-content` directory. - After unzipping, the directory structure should look like this : - - `wp-content` - `->plugins` - `->themes` - `->pg4wp` - `db.php` - `[maybe other files/directories]` - - The key is the presence of `pg4wp/` and `db.php` in `wp-content` +1. Unzip the files and put the `pg4wp` directory in your `/wp-content/plugins` directory. -1. Edit `db.php` to configure the database driver you wish to use +1. Copy the `dp.php` from the `pg4wp` directory to `wp-content` + You can modify this file to configure the database driver you wish to use Currently you can set 'DB_TYPE' to 'pgsql' or 'mysql' You can also activate DEBUG logs @@ -59,6 +50,13 @@ There is no screenshot for this plugin == Changelog == += 1.0.1 = +* Reorganisation of directory structure +* Updated installation procedure +* Changed the fake server version to 4.1.3 +* Added support for Unix socket connections (just leave the "host" field empty when installing) + + = 1.0.0 = * Initial stable release. * Code optimisation and reorganisation.