PDO For WordPress 1.0.0

Hello all!

finally i’ve released version 1.0.0 of the PDO For WordPress package.

This is compatible with versions of WordPress from 2.3 to 2.5.1 and has also fixed some bugs in WP itself (in the 2.5 trunk).

I have, for the first time, published this release on wp.org. You can find it at HERE

Please feel free to leave comments/feedback either here or on the trac at wp.

sorry for the delay, and thanks to Ulf Ninow (fnumatic) for his pointer on class inheritance. it makes upgrade management much easier.

enjoy
Justin

25 Comments

nanxiaoJune 28th, 2008 at 9:37 am

Hi,I install the wordpress 2.5.1 wiht you pdo plugins,but the Manage comments box do not display the comments, is it a bug?

JustinJune 28th, 2008 at 9:44 am

Hi, I don’t think so. I have not seen the same behaviour, but will test it. Are you using any other plugins? if so, please let me have a list so that i can replicate your environment.

[...] just posted a comment here. Having originally thought this was due to a badly behaved plugin, i’ve just looked at it [...]

nanxiaoJune 28th, 2008 at 12:41 pm

None plugins, I have deleted all the plugings,but the Manage comments box do not display the comments any more.
Apache 2.0.63 ;php 5.2.6;open eAccelerator and Zend Optimizer

JustinJune 28th, 2008 at 3:37 pm

Thanks. I found the bug and have posted about it in the blog.
a fix has been posted on the wordpress plugins site.

JoelsonOctober 17th, 2008 at 7:37 pm

Justin hello I need your help

Here I am trying to install the script WordPress, with the use ODP, follow the steps you had in step by step, but I get the following message

Invalid or missing PDO Driver
Your PHP installation appears not to have the right PDO drivers loaded. These are required for this version of WordPress and the type of database you have specified.

Note: I am installing on the server intranet of the company that work, and the system of the database is SQL Server 2005 or higher

What should I pass the parameters in wp-config.php?

define ( ‘DB_TYPE’, ‘sqlite’), or define ( ‘DB_TYPE’, ‘PDO_DBLIB’);?

I did an installation on my personal machine localhost, with version 2.5.1 of WordPress, this apparent installed, but when I check in mysql, don’t found there is the tables.

Until the moment I do not know what to do, if you can help me I would be very grateful

JustinOctober 17th, 2008 at 7:53 pm

@Joelson: Hi, I don’t believe that anyone has written a driver for SQL Server yet. currently supported are sqlite and mysql.

[...] 于是我就在fcicq留了个言热心的fcicq给了我回复。给我推荐了一个用于Wordpress的Sqlite插件PDO For WordPress [...]

MartinJanuary 18th, 2009 at 2:23 am

Hi,
First thanks for this great plugin. I was looking for something like that for ages. THANKS!!!
Secondly – will you support WP 2.7?

JustinJanuary 18th, 2009 at 10:07 am

@Martin: Hi, i’m pretty sure that the code does support wp2.7 already. at least as a clean installation. the code does not support upgrades yet as WP uses a proprietary function called dbdelta() that makes use of ALTER statements, which are very poorly supported in sqlite. i’m working on a workaround for this, but it is low priority.

if you find that the code is not working in 2.7 let me know. i have some development code in testing that should improve things.

MartinJanuary 18th, 2009 at 11:54 am

Justin, so how do you do upgrades :) – dump, fresh install and reload? any scripts for that? ;)

Thanks again I’ll let you know how it went with 2.7

JustinJanuary 18th, 2009 at 12:43 pm

@Martin:

So far I have not had to worry about it as there have been no schema changes recently. I guess if there were one then I would use it as impetus for writing the driver for ALTER queries.

MartinJanuary 18th, 2009 at 12:46 pm

Great :) – this sounds just perfect. Thanks again for this plugin and such prompt replies! All the best to you!

MartinJanuary 19th, 2009 at 9:46 pm

Hmmm,

I did those 2 steps as in README and I get database connection error. I have sqlite support with my php.
How can I debug this?

JustinJanuary 19th, 2009 at 10:14 pm

@Martin:

What version of the plugin are you using?
For wp 2.7 you will need to add the following to the class in pdo/db.php

Function db_version(){
 return '5.0';
}
MartinJanuary 19th, 2009 at 10:28 pm

I use 1.0.2 – adding this function to mentioned file didn’t help.

MartinJanuary 19th, 2009 at 10:30 pm

Justin do you use any IM? Like maybe ICQ or something?

MartinJanuary 19th, 2009 at 10:51 pm

Replied :) – I’m stupid ;) – I have unpacked stuff into / not /wp-content – now things seem to work. BIG THANKS!!!

Bryce NewallJanuary 23rd, 2009 at 9:09 am

Hello,

I’m experiencing the same problem to what Martin was going through. I did make sure I unpacked into the correct directory, and I made the change you mentioned above to pdo/db.php. This is with WordPress 2.7 and PDO for WordPress 1.0.2. I’m running on a Debian Linux virtual private server. I thought maybe installing the “php5-sqlite” package would help, but it only made things worse. Now, instead of the “Invalid or missing PDO driver”, I’m getting “Fatal error: Call to a member function bail() on a non-object in /wp-content/pdo/PDOEngine.php on line 77″. If I remove the “php5-sqlite” package, then I’m back to “Invalid or missiong PDO driver”.

Any thoughts?

Thank!

JustinJanuary 23rd, 2009 at 12:21 pm

@Bryce Newall: Hi Bryce
thanks for trying out the plugin.
the first error you get is because you did not have sqlite installed. according to the manual you need to configure php thus

./configure --with-zlib --enable-pdo=shared --with-pdo-sqlite=shared --with-sqlite=shared

and then you need to enable the pdo.so extension in your php.ini

the manual reference is: : http://fr2.php.net/manual/en/pdo.installation.php

the second error exists because somehow you are getting an error for which the plugin (and WP) wants to bail out gracefully but cannot. this is a good spot (thanks) and will be fixed in a later version.

you can fix the error now by adding this line

global $wpdb;

to the method connect()

private function connect($connectionParams){
  global $wpdb; // < -- new line to be added
...

in pdo/PDOEngine.php

however this does not address why the underlying error is happening. From the line reference I can determine that the error is triggering because the script does not have adequate permissions to create the directory necessary for the storage of the sqlite database. you can fix this by creating a folder called ‘database’ in wp-content. please make sure that the permissions on the folder are adequate for the php process to read and write to files within it. I use 0777 (global access) as I then secure the database and directory with .htaccess.

Regrettably this is not something that the plugin can circumvent (well, there are ways, but I don’t see it as the plugin’s problem…).

hth,
Justin

Bryce NewallJanuary 23rd, 2009 at 4:26 pm

Hello Justin,

Thanks! That did the trick. Once that was done, though, I had to go in and tweak my Apache settings, since the Apache processes suddenly ballooned up to 13-16 MB each and ate up all of my VPS’ memory. Reducing the number of Apache processes did the trick, though.

– Bryce

MichaelFebruary 2nd, 2009 at 6:27 am

I really like the idea of your plugin, but I’m having a hard time getting it to work. I did a fresh installation of WP 2.7 and got sqlite installed, and added the appropriate extensions to my php.ini file. When I go to my site it starts to run through the basic setup again (like it did the first time with the MySQL database). However, after putting in my site title and e-mail, the next page (/wp-admin/install.php?step=2) fails with an error:

Error occurred at line 335 in Function prepareQuery.
Error message was: Problem preparing the PDO SQL Statement. Error was Array ( [0] => HY000 [1] => 1 [2] => no such table: wp_options )

(There’s more, but I wasn’t sure how much detail you needed.) I’m running PHP v. 5.2.3 with Apache 2.2.4 on Ubuntu 7.10, with pdo_sqlite v. 1.10.2.6 and version 3.2.8 of the SQLite library. I think it’s awesome that you developed this, and I appreciate any help you can offer.

-Michael

JustinFebruary 2nd, 2009 at 7:34 am

@Michael:

Hi Michael
the error is not so much a plugin error but sqlite/pdo telling you that the query is incorrect. in this case it is telling you that wp_options does not exist, which is indicative that something has gone wrong in the installation.
can you post your wp-config here please? or if you would rather do so offline, mail me at the address provided in http://rathercurious.net/about

ManuMarch 21st, 2009 at 3:44 pm

Hi,

I’m trying to setup wordpress w/ PDO, with php5 and lighttpd. Trouble is, I get nothing ;-)

It seems the server executes the request, but the browser receives an empty reply. I see no error in the server log files, no crash, nothing.
The only message I’ve been able to receive for now is the plugin complaining about an unsupported PDO driver – when I alter the “DB_TYPE” parameter on purpose to trigger an error: at least some of the files are parsed and executed. As soon as I revert back to the proper configuration (DB_TYPE = “sqlite”), I only receive blank pages
php_info() reports no issue, PDO driver is properly loaded.

I also tried to run the CLI version of PHP5 to get more info, with no luck. When I use ‘strace’ to see the system call, everything looks normal, but the execution stops without any obvious error:
{{{
lstat64(“/var”, {st_mode=S_IFDIR|0755, st_size=336, …}) = 0
lstat64(“/var/www”, {st_mode=S_IFDIR|0755, st_size=152, …}) = 0
lstat64(“/var/www/wordpress”, {st_mode=S_IFDIR|0775, st_size=944, …}) = 0
lstat64(“/var/www/wordpress/wp-content”, {st_mode=S_IFDIR|0775, st_size=232, …}) = 0
lstat64(“/var/www/wordpress/wp-content/pdo”, {st_mode=S_IFDIR|0775, st_size=136, …}) = 0
lstat64(“/var/www/wordpress/wp-content/pdo/PDOEngine.php”, {st_mode=S_IFREG|0664, st_size=16641, …}) = 0
gettimeofday({1237646717, 948278}, NULL) = 0
open(“/var/www/wordpress/wp-content/pdo/PDOEngine.php”, O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0664, st_size=16641, …}) = 0
read(3, “$m){\n\t\t\t$output “…, 8192) = 8192
read(3, “truct($value,$node->$key); \n “…, 8192) = 257
read(3, “”…, 8192) = 0
read(3, “”…, 8192) = 0
close(3) = 0
gettimeofday({1237646717, 999405}, NULL) = 0
lstat64(“/var”, {st_mode=S_IFDIR|0755, st_size=336, …}) = 0
lstat64(“/var/www”, {st_mode=S_IFDIR|0755, st_size=152, …}) = 0
lstat64(“/var/www/wordpress”, {st_mode=S_IFDIR|0775, st_size=944, …}) = 0
lstat64(“/var/www/wordpress/wp-includes”, {st_mode=S_IFDIR|0775, st_size=2400, …}) = 0
lstat64(“/var/www/wordpress/wp-includes/wp-db.php”, {st_mode=S_IFREG|0664, st_size=25032, …}) = 0
gettimeofday({1237646718, 16978}, NULL) = 0
open(“/var/www/wordpress/wp-includes/wp-db.php”, O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0664, st_size=25032, …}) = 0
read(3, “<?php\n/**\n * WordPress DB Class\n “…, 8192) = 8192
read(3, “db) {\n\t\tif (!@mysql_select_db($db”…, 8192) = 8192
read(3, “\t\tforeach ( (array) array_keys($d”…, 8192) = 8192
brk(0x74f000) = 0x74f000
read(3, “tring false on failure, version n”…, 8192) = 456
read(3, “”…, 8192) = 0
read(3, “”…, 8192) = 0
close(3) = 0
close(2) = 0
close(1) = 0
munmap(0×40020000, 4096) = 0
close(0) = 0
munmap(0x4001f000, 4096) = 0
brk(0x6cb000) = 0x6cb000
munmap(0x40abe000, 528384) = 0
open(“/dev/urandom”, O_RDONLY) = 0
read(0, “\31\303cq”…, 4) = 4
close(0) = 0
open(“/dev/urandom”, O_RDONLY) = 0
read(0, “\210\337\22m”…, 4) = 4
close(0) = 0
open(“/dev/urandom”, O_RDONLY) = 0
read(0, “1\22~v”…, 4) = 4
close(0) = 0
setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={0, 0}}, NULL) = 0
munmap(0x40a3c000, 93572) = 0
munmap(0x40a53000, 364456) = 0
munmap(0x409b0000, 50136) = 0
munmap(0x409cc000, 457360) = 0
munmap(0×40993000, 117656) = 0
brk(0×645000) = 0×645000
exit_group(255) = ?
}}}

I’m out of idea to solve this issue. Any hints?

JustinMarch 21st, 2009 at 4:15 pm

@Manu:
Hi, what version of WP are you using?

Leave a comment

Your comment