PDO For WordPress – update
after nearly a year of absence i have updated PDO for WordPress to function with WP 2.7.1. In the same breath i have also changed many of the regex calls in the sqlite driver to use sqlite UDF’s (user defined functions) instead. there should be a measurable performance gain over previous versions.
the latest version is already available on wp.org.
Thank you very much for this plugin! My host charges me extra for MySQL databases, but not SQLite databases. Thank you for helping me save on hosting charges.
Hi,
It’d be nice if you updated the installation blurb on the plugin site to mention that the sqlite support expects to be able to write its database file to wp-content/database, and thus the webserver needs write access there.
Thanks!
@pratfall:
the installation routine should inform you if it is not able to create the directory ‘database’ in wp-content and it should also inform you if it is not able to write to the new directory. it attempts to create both with 0777 permissions (and then protects the directory with .htaccess). See lines 73-87 of PDOEngine.php.
to be honest if users are unfamiliar with debugging and perms etc then changing the back-end of a tool like WP is _not_ a good idea at all. there are too many plugins etc that can break the query transformations and if you are not properly experienced then all you’re going to see is something between a blank screen and a screen of garbage.
that said, for those that wish to take the risk there is no harm in pointing out the obvious in the readme file.
What am I doing wrong?
WordPress
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.
PDO
PDO support enabled
PDO drivers sqlite2, sqlite, mysql
pdo_mysql
PDO Driver for MySQL, client library version 5.0.16
pdo_sqlite
PDO Driver for SQLite 3.x enabled
PECL Module version (bundled) 1.0.1 $Id: pdo_sqlite.c,v 1.10.2.6.2.3 2007/12/31 07:20:10 sebastian Exp $
SQLite Library 3.3.7
@Francis Maile:
can you run this code on your php server and post back the response
Greetings!
I’m having trouble getting PDO working under WordPress 2.7.1. I made the required changes to wp-config.php (I’m not a PHP expert, by the way), but when I try to bring up my site, instead of attempting to create the database, or even showing me a message saying it couldn’t create the database, I get this:
Fatal error: Call to a member function bail() on a non-object in /home/smacsdb/www/wp-content/pdo/PDOEngine.php on line 77
I looked at line 77 of that php file, and it appears to be calling that “bail” routing, possibly because it couldn’t create the database. That I can probably fix, but I’m wondering about the actual error message I’m getting?
Thanks!
@Bryce Newall:
Hi bryce
What version of the plugin are you using?
I downloaded version 2.0.0, the latest one on the WP web site.
@Bryce Newall:
ok.
the issue is that $wpdb is not made global in the connect method. i will upload a version 2.1.0 in the next few minutes.
but this is only a symptom of your issue, rather than the cure. the issue you have is that the plugin cannot create the necessary folder for your database (wp-content/database) due to permissions problems.
can you run this code on your php server and post back the response
print_r(PDO::getAvailableDrivers());
I get this output:
Array ( [0] => sqlite2 [1] => sqlite [2] => mysql )
I cant get past “Your PHP installation appears to be missing the PDO extension which is required for this version of WordPress.”
If I try print_r(PDO::getAvailableDrivers()); I get an error saying PDO class not found.
Using PHP 5.0.5
Any ideas?
@Jim:
I assume that you do have pro-sqlite installed? The error received suggests that you do not and that additionally you have not installed the pdo base library. Look at http://www.php.net/pdo for installation instructions.
Hi Justin, sqlite is installed, but you are correct. I realised my php install does not have pdo support. I’m not likely to get it either as the server I’m using for this is a discreet NAS device (Thecis N2100) which i am unable to compile code for, so getting the pdo.so isnt an option and neither is upgrading my version of php. Thanks anyway.
@Jim:
surely you should be able to install PDO to a thecus box. although i don’t have one to check on.
do you have terminal and root access? is PECL installed? can you compile on the thecus? otherwise you can get the appropriate cross-compiler toolchain and rebuild the php binary on another machine.
@Francis Maile:
Hi Francis
the error message you get is from line 73 of wp-content/db.php (in version 2.1.0). it means that the driver that you have _requested_ is not loaded. it takes the request from your DB_TYPE definition in wp-config.php. this is not case sensitive btw but elsewhere there is case sensitivity so please make sure you use lower case.
so, please check carefully your wp-config.php file and make sure that DB_TYPE and its definition is spelled correctly.
From the installation notes in the readme file you should see:
—– wp-config.php —–
this line of code is placed directly after the define(‘COLLATE’,”); line:
define(‘DB_TYPE’, ‘sqlite’); //mysql or sqlite
—–
hi Justin
I tried, but i got an error:
Your PHP installation appears to be missing the MySQL which is required for WordPress.
i run this code
print_r(PDO::getAvailableDrivers());
then response
Array ( [0] => sqlite2 )
Something i’m missing out?
I’m a chinese user,so english not very well ~~
Thank you very much!
@Michael: Hi
i am quite sure that your english is better than my chinese…
the error message you post is not one of mine (see lines 65-75 of wp-content/db.php).
however i can see from the response to PDO::getAvailableDrivers that you have the pdo extension loaded but do not have the sqlite3 extension loaded (which is a requirement). please see http://www.php.net/pdo for instructions on how to install the PDO drivers for your server type.
It works!
Thank you!
Hi there…just so you know, something got garbled with your latest release to the wp plugins site:
* Clicking the download button is the only way to get something called version 2.1.0, but that zip file has a db.php and readme file and nothing else (no pdo dir or anything in it)
* If you click on the “download other versions”, you can get 2.0.0, but attempting to use the 2.1.0 db.php with 2.0.0 generates a lot of errors.
I just downloaded 2.1.0, and it took like a half hour before I could figure out I was missing like half of the plugin. I went to 2.0.0 and everything seems to work great. Thanks!
@Craig:
Thanks. I will check it out soon as possible.
@Craig:
this is fixed now. it may take a half-hour or so for the svn rescan on WP to happen.
Looks like it still is messed up over at wp. I downloaded what is labeled as v2.2.0, but it is missing the file PDOEngine.php. I was able to go back to version 2.0.0 and extract that file.
WordPress v2.7.1
PHP 5.1.6
PDO drivers mysql, odbc, pgsql, sqlite
It also appears that this plugin is incompatible with PHP5 < 5.2.0 as you are using preg_last_error() in pdo_sqlite_driver_create. Since it appears that you are using this simply for debugging, I went ahead and commented that line to see if I can get it to work with PHP5.1.6 (the standard for RHEL5). It created the MyBlog.sqlite and .htaccess files, but appears to not have been able to create the tables as it errors at step 2 when it attempts to prepare a statement that selects from wp_options (since there is no table wp_options yet). I see that commenter Michael ran into this exact same issue on February 2nd, 2009. Can you share what the solution was for him?
Also, I’d be interested in helping to develop an Oracle driver as that is what i /really/ need to use (sqlite is a stop-gap solution).
@Gilzow:
darn darn darn…. i can’t work out why the svn commit isn’t taking. My client is reporting that all is tickity boo… I will investigate.
In the meantime I have sent you the archive by mail. I suspect that the problem you have relates to an older version of the plugin as the recent versions have resolved the commented issue.
I regret that i know nothing about oracle’s sql language. That said, i’m happy to work on it with you.
@Gilzow:
oh yes, and the preg_last_error is just for debugging, as you said.
Just wanted to say “THANK YOU” to justin for his assistance. We were able to get everything working. In my specific case, I had to chmod wp-contents to 777 temporarily for it to install successfully. Afterwards I was able to change it back to 775 and it is working fine.
When I run WP and the PDO Sqlite plugin nothing appears on the screen.
If I modify the wp-config.php and remove define(‘DB_TYPE’, ‘sqlite’); I receive 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.
Here is my configuration:
PHP 5.2.9
Array ( [0] => odbc [1] => sqlite )
I am running the old version of your PDO Sqlite plugin on a number of sites on the same server without issue.
Thanks.
@D_Mann:
the error you get is because DB_TYPE needs to be defined in order to work with my code. and my code is triggered simply by putting db.php into wp-content. in db.php there is a test for whether the PDO_Extension called DB_TYPE is installed. if DB_TYPE is blank/undefined the code looks for a PDO_Extension that is blank. Since there is none, you get the error.
there was a bug that crept in at some version which killed installation. the bug was fixed in version 2.0.0 and 2.2.0 (at wp.org). if you have previously had the error you need to delete wp-content/database prior to reattempting the install. I will improve this flow in a later release.
Hi,
C:\Documents and Settings\processor>php -r print_r(PDO::getAvailableDrivers());
Array
(
[0] => sqlite
[1] => sqlite2
)
C:\Documents and Settings\processor>php-cgi -v
PHP 5.2.9-2 (cgi-fcgi) (built: Apr 9 2009 08:23:17)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
PDO plugins v2.2.0 installed on wp-content
define(‘DB_COLLATE’, ”);
define(‘DB_TYPE’, ‘sqlite’);
all requirement done,
define(‘DB_NAME’, ‘wp271.db’);
define(‘DB_USER’, ‘wp271user’);
define(‘DB_PASSWORD’, ‘wp271pass’);
as i want to use sqlite db backend.
that db file already created manually on root / directory
but seem wp can’t find the db for modification or creating table
any help would be appreciated.
Thanks.
@Fery: i don’t recommend creating the database file manually. Let SQLite do all the work to guarantee a clean file creation.
i have updated the plugin to version 2.3.0 and posted it on WP.org. Please upgrade to the new version and see whether that helps – i have changed slightly the way that the installation works.
about v2.3.0
————————-
Error installing the database
Query was ; CREATE TABLE IF NOT EXISTS wp_terms ( term_id integer NOT NULL PRIMARY KEY AUTOINCREMENT , name text NOT NULL default ”, slug text NOT NULL default ”, term_group integer NOT NULL default 0) ; CREATE UNIQUE INDEX IF NOT EXISTS slug_37 on wp_terms (slug); CREATE INDEX IF NOT EXISTS name_25 on wp_terms (name).
Error message was: Array ( [0] => HY000 [1] => 6 [2] => database table is locked ) Error installing the database
Query was ; CREATE TABLE IF NOT EXISTS wp_term_taxonomy ( term_taxonomy_id integer NOT NULL PRIMARY KEY AUTOINCREMENT , term_id integer NOT NULL default 0, taxonomy text NOT NULL default ”, description text NOT NULL, parent integer NOT NULL default 0, count integer NOT NULL default 0) ; CREATE UNIQUE INDEX IF NOT EXISTS term_id_taxonomy_44 on wp_term_taxonomy (term_id,taxonomy).
Error message was: Array ( [0] => HY000 [1] => 6 [2] => database table is locked ) Error installing the database
Query was ; CREATE TABLE IF NOT EXISTS wp_term_relationships ( object_id integer NOT NULL default 0, term_taxonomy_id integer NOT NULL default 0, term_order integer NOT NULL default 0, PRIMARY KEY (object_id,term_taxonomy_id) ) ; CREATE INDEX IF NOT EXISTS term_taxonomy_id_41 on wp_term_relationships (term_taxonomy_id).
Error message was: Array ( [0] => HY000 [1] => 6 [2] => database table is locked ) Error installing the database
Query was ; CREATE TABLE IF NOT EXISTS wp_comments ( comment_ID integer NOT NULL PRIMARY KEY AUTOINCREMENT , comment_post_ID integer NOT NULL default ’0′, comment_author blob NOT NULL, comment_author_email text NOT NULL default ”, comment_author_url text NOT NULL default ”, comment_author_IP text NOT NULL default ”, comment_date text NOT NULL default ’0000-00-00 00:00:00′, comment_date_gmt text NOT NULL default ’0000-00-00 00:00:00′, comment_content text NOT NULL, comment_karma integer NOT NULL default ’0′, comment_approved text NOT NULL default ’1′, comment_agent text NOT NULL default ”, comment_type text NOT NULL default ”, comment_parent integer NOT NULL default ’0′, user_id integer NOT NULL default ’0′) ; CREATE INDEX IF NOT EXISTS comment_approved_19 on wp_comments (comment_approved); CREATE INDEX IF NOT EXISTS comment_post_ID_21 on wp_comments (comment_post_ID); CREATE INDEX IF NOT EXISTS comment_approved_date_gmt_26 on wp_comments (comment_approved,comment_date_gmt); CREATE INDEX IF NOT EXISTS comment_date_gmt_25 on wp_comments (comment_date_gmt).
Error message was: Array ( [0] => HY000 [1] => 6 [2] => database table is locked ) Error installing the database
Query was ; CREATE TABLE IF NOT EXISTS wp_links ( link_id integer NOT NULL PRIMARY KEY AUTOINCREMENT , link_url text NOT NULL default ”, link_name text NOT NULL default ”, link_image text NOT NULL default ”, link_target text NOT NULL default ”, link_category integer NOT NULL default ’0′, link_description text NOT NULL default ”, link_visible text NOT NULL default ‘Y’, link_owner integer NOT NULL default ’1′, link_rating integer NOT NULL default ’0′, link_updated text NOT NULL default ’0000-00-00 00:00:00′, link_rel text NOT NULL default ”, link_notes text NOT NULL, link_rss text NOT NULL default ”) ; CREATE INDEX IF NOT EXISTS link_category_33 on wp_links (link_category); CREATE INDEX IF NOT EXISTS link_visible_7 on wp_links (link_visible).
Error message was: Array ( [0] => HY000 [1] => 6 [2] => database table is locked ) Error installing the database
Query was ; CREATE TABLE IF NOT EXISTS wp_options ( option_id integer NOT NULL PRIMARY KEY AUTOINCREMENT , blog_id integer NOT NULL default ’0′, option_name text NOT NULL default ”, option_value text NOT NULL, autoload text NOT NULL default ‘yes’) ; CREATE INDEX IF NOT EXISTS option_name_16 on wp_options (option_name).
Error message was: Array ( [0] => HY000 [1] => 6 [2] => database table is locked ) Error installing the database
Query was ; CREATE TABLE IF NOT EXISTS wp_postmeta ( meta_id integer NOT NULL PRIMARY KEY AUTOINCREMENT , post_id integer NOT NULL default ’0′, meta_key text default NULL, meta_value text ) ; CREATE INDEX IF NOT EXISTS post_id_42 on wp_postmeta (post_id); CREATE INDEX IF NOT EXISTS meta_key_23 on wp_postmeta (meta_key).
Error message was: Array ( [0] => HY000 [1] => 6 [2] => database table is locked ) Error installing the database
Query was ; CREATE TABLE IF NOT EXISTS wp_posts ( ID integer NOT NULL PRIMARY KEY AUTOINCREMENT , post_author integer NOT NULL default ’0′, post_date text NOT NULL default ’0000-00-00 00:00:00′, post_date_gmt text NOT NULL default ’0000-00-00 00:00:00′, post_content text NOT NULL, post_title text NOT NULL, post_category integer NOT NULL default ’0′, post_excerpt text NOT NULL, post_status text NOT NULL default ‘publish’, comment_status text NOT NULL default ‘open’, ping_status text NOT NULL default ‘open’, post_password text NOT NULL default ”, post_name text NOT NULL default ”, to_ping text NOT NULL, pinged text NOT NULL, post_modified text NOT NULL default ’0000-00-00 00:00:00′, post_modified_gmt text NOT NULL default ’0000-00-00 00:00:00′, post_content_filtered text NOT NULL, post_parent integer NOT NULL default ’0′, guid text NOT NULL default ”, menu_order integer NOT NULL default ’0′, post_type text NOT NULL default ‘post’, post_mime_type text NOT NULL default ”, comment_count integer NOT NULL default ’0′) ; CREATE INDEX IF NOT EXISTS post_name_24 on wp_posts (post_name); CREATE INDEX IF NOT EXISTS type_status_date_4 on wp_posts (post_type,post_status,post_date,ID).
Error message was: Array ( [0] => HY000 [1] => 6 [2] => database table is locked ) Error installing the database
Query was ; CREATE TABLE IF NOT EXISTS wp_users ( ID integer NOT NULL PRIMARY KEY AUTOINCREMENT , user_login text NOT NULL default ”, user_pass text NOT NULL default ”, user_nicename text NOT NULL default ”, user_email text NOT NULL default ”, user_url text NOT NULL default ”, user_registered text NOT NULL default ’0000-00-00 00:00:00′, user_activation_key text NOT NULL default ”, user_status integer NOT NULL default ’0′, display_name text NOT NULL default ”) ; CREATE INDEX IF NOT EXISTS user_login_key_4 on wp_users (user_login); CREATE INDEX IF NOT EXISTS user_nicename_17 on wp_users (user_nicename).
Error message was: Array ( [0] => HY000 [1] => 6 [2] => database table is locked ) Error installing the database
Query was ; CREATE TABLE IF NOT EXISTS wp_usermeta ( umeta_id integer NOT NULL PRIMARY KEY AUTOINCREMENT , user_id integer NOT NULL default ’0′, meta_key text default NULL, meta_value text ) ; CREATE INDEX IF NOT EXISTS user_id_15 on wp_usermeta (user_id); CREATE INDEX IF NOT EXISTS meta_key_14 on wp_usermeta (meta_key).
Error message was: Array ( [0] => HY000 [1] => 6 [2] => database table is locked )
———————–
that’s the error info in the head of every page
———————
when install WordPress 2.6.5 en final
——————
ps : if the permalinks setting is :
/%year%%day%/%post_id%.html or
/%year%%monthnum%/%post_id%.html (whit day or month)
all of the post pages will be “404″
———————
hope hope hope ~~~ your fix ~~~~ the very very good plugins~~~
来自中国用户的期待 和感谢
@oursolo:
well spotted!
that’s a fairly major error to get through testing unscathed!
i have uploaded a bug-fix to WP.Org as version 2.4.0. please redownload from there. It may take half an hour or so to be refreshed by the svn parsing software.
about v2.4.0
tested , v2.3.0 ‘s bug have fixed in 2.4.0, so quickly ~ !
but there is a new problem in v2.4.0
————————-
after install, post some artical
if open the ” Permalinks ”
then into the “Edit Post or Manage Posts” ,there show “No posts found.”
and in the index page of the web ,page show ” no found ”
———
if open the ” Permalinks ”
some times, can’t post new artical, return page “Your attempt to edit this post: “sadfs Write PostWrite Post” has failed.Please try again.
”
but some times, can publish …..
——–
under WordPress 2.6.5 en final & 2.7.1
——-
hope for your fix , extremely grateful to you!!
@oursolo:
What permalink structures are you using ?
Using v2.4.0 still the same
looks like db create process lost somewhere
no database folder created
no MyBlog.sqlite db created
no error on php error_log
if i add fastcgi option with -s, the browser show the code of “wordpress/index.php”
or i still miss something on webserver config, but if i call test.php with phpinfo(); on it , the page is fine as expected
Thank you.
re:
Justin
What permalink structures are you using ?
————————–
before v2.3.0, set permalink with “%day% or %monthnum% ” will be 404 error
demo:
/%year%%day%/%post_id%.html or
/%year%%monthnum%/%post_id%.html
but ,if only use “%year% , just like “/%year%/%post_id%.html” , run well , no 404
in v2.4.0 use permalink by any setting, will be 404 error
@Fery:
not sure what could be wrong, I’m afraid. it installs fine on my machine.
if you want me to debug further i’m happy to look at your machine but you will need to supply remote access credentials. Don’t post them publicly (of course!), ping them to me at justin.adie@gmail.com
When I replaced PDO from 1.0.2 to 2.4.0, any post is not displayed. It seems PDO try to create tables. I think SQL in the line 100 of PDOEngine.php should be ‘select count(*) from SQLite_Master’.
@hiro: you are right. I noticed this earlier today. I have been having issues with the svn upload and I think an early debut version got uploaded. I will take a look this evening
hiro, oursolo
thank you for pointing out these issues. I think they were, in fact, the same thing.
i very much hope that i have now fixed these problems and we have a stable version of PDO For WordPress once more. Version 2.5.0 was uploaded to wp.org about 10 minutes ago. It should be available for download in the next half-hour.
Please do post back with your experiences with the new version. This time, date based permalinks should also work.
about v2.5.0
still the same problem about the permalink
————————-
if set permalink with “%day% or %monthnum% or %hour% or….. ” ,the postview pages will be 404 error
test demo:
/%day%/%post_id%.html or
/%monthnum%/%post_id%.html
still the same ,only use “%year% , just like “/%year%/%post_id%.html” , run well , no 404
—————
for test the URL rewrite & .htaccess , i change db to mysql, then the permalink run well , no problem ,so i guess , the sever’s system should be ok ?
Justin ,don’t have too much pressure, take your time~~~ hehe~~ thank you one more time~~
@oursolo:
that’s strange – it’s working on my test server. i will investigate further tomorrow.
v2.5.0 works fine and succeeded to upgrade WP to 2.7.1. Thank you !
It’s on Windows from the beginning
using v2.5.0
after i switch webserver from nginx-for-win to abyss-for-win now php.log contain many error
[05-May-2009 21:30:05] PHP Notice: Use of undefined constant DB_TYPE – assumed ‘DB_TYPE’ in D:\Abyss\htdocs\wp-content\db.php on line 73
[05-May-2009 21:36:28] PHP Notice: Use of undefined constant ABSPATH – assumed ‘ABSPATH’ in D:\Abyss\htdocs\wp-content\db.php on line 134
[05-May-2009 21:36:28] PHP Notice: Use of undefined constant ABSPATH – assumed ‘ABSPATH’ in D:\Abyss\htdocs\wp-content\db.php on line 135
[06-May-2009 19:12:49] PHP Notice: Use of undefined constant DB_USER – assumed ‘DB_USER’ in D:\AbyssX225\htdocs\wp-content\pdo\db.php on line 234
[06-May-2009 19:12:49] PHP Notice: Use of undefined constant DB_PASSWORD – assumed ‘DB_PASSWORD’ in D:\AbyssX225\htdocs\wp-content\pdo\db.php on line 234
[06-May-2009 19:12:49] PHP Notice: Use of undefined constant DB_NAME – assumed ‘DB_NAME’ in D:\AbyssX225\htdocs\wp-content\pdo\db.php on line 234
[06-May-2009 19:12:49] PHP Notice: Use of undefined constant DB_HOST – assumed ‘DB_HOST’ in D:\AbyssX225\htdocs\wp-content\pdo\db.php on line 234
[06-May-2009 19:12:49] PHP Notice: Use of undefined constant DB_TYPE – assumed ‘DB_TYPE’ in D:\AbyssX225\htdocs\wp-content\pdo\db.php on line 234
[06-May-2009 19:08:03] PHP Notice: Use of undefined constant DB_USER – assumed ‘DB_USER’ in D:\AbyssX225\htdocs\wp-includes\wp-db.php on line 992
[06-May-2009 19:08:03] PHP Notice: Use of undefined constant DB_PASSWORD – assumed ‘DB_PASSWORD’ in D:\AbyssX225\htdocs\wp-includes\wp-db.php on line 992
[06-May-2009 19:08:03] PHP Notice: Use of undefined constant DB_NAME – assumed ‘DB_NAME’ in D:\AbyssX225\htdocs\wp-includes\wp-db.php on line 992
[06-May-2009 19:08:03] PHP Notice: Use of undefined constant DB_HOST – assumed ‘DB_HOST’ in D:\AbyssX225\htdocs\wp-includes\wp-db.php on line 992
[06-May-2009 19:14:23] PHP Notice: Use of undefined constant ABSPATH – assumed ‘ABSPATH’ in D:\AbyssX225\htdocs\wp-content\pdo\driver_sqlite\schema.php on line 16
[06-May-2009 19:14:23] PHP Notice: Undefined variable: wp_version in D:\AbyssX225\htdocs\wp-content\db.php on line 146
after every variable i change to real /path/to/expected everything just fine
Thanks afterall ^^
@Fery:
Those errors indicate that you have not defined DB_TYPE in wp_config.php as per the install instructions.
Got a blank page with status 500. Running under spawn-fcgi. PHP error log is empty.
When changing pdo/db.php:37 to this:
global $wpdb; $wpdb = 1;
the blank page changes to a long screen of sql-related errors like this:
«Error installing the database
Query was ; CREATE TABLE IF NOT EXISTS wp_terms ( term_id integer NOT NULL PRIMARY KEY AUTOINCREMENT , name text NOT NULL default ”, slug text NOT NULL default ”, term_group integer NOT NULL default 0) ; CREATE UNIQUE INDEX IF NOT EXISTS slug_13 on wp_terms (slug); CREATE INDEX IF NOT EXISTS name_38 on wp_terms (name).
Error message was: Array ( [0] => HY000 [1] => 1 [2] => near “NOT”: syntax error )»
@Peter:
Can you let me know what version of the plugin and wp you are using please.
With a pleasure — I like debugging
Plugin 2.5.0
WP 2.7.1
PHP 5.2.4
print_r(PDO::getAvailableDrivers()); -> Array([0] => sqlite)
If it helps: Ubuntu 8.04.2, on kernel 2.6.18, on VPS (OpenVZ)
@Peter:
that’s curious. i thought all the installation bugs had been ironed out now.
could you try renaming the database directory (say database_old) and trying to install again?
I’v renamed the db directory and ran the installation, but with the same result.
I think, the problem may be in my php installation. I’m a novice in php-based applications, so all the software may have been installed in a wrong way. What steps could I take to get the right php environment (with pdo, pdo_sqlite) on a modern linux?
Thanks a lot for your help
@Peter:
Occams razor suggests that the plugin is at fault. but i suspect it’s more the unfamiliar (to me) method of using php and the resulting permissions issues.
please try creating the directory ‘wp-content/database’ by hand and expressly setting the perms to 0777 on the directory and all inheritors.
then re-run the plugin.
good luck !
Nothing changed
That was already set to 777. I have only two users on my vps: “www” and “root”. All turns was done under “www” one. It creates ok the zero-sized MyBlog.sqlite file (and the .htaccess too).
May be I have different version of sqlite?
Error messages are strange because of “near “NOT”: syntax error”. How can I check the version of installed sqlite engine?
Hello,
I have installed your plugin and wordpress on fresh system. I have modified wp-config.php. But when I run install I see empty page. I have made some searching and found out the script last processed is db.php. It probably stops on line require_once PDODIR.’db.php’;.
The directory called is /mnt/www/www/wordpress//wp-content/pdo/db.php I wonder why the script is calling itself, and why is the direcory with two //.
Could you look on this problem?
Adam
Well, I found the mistake in define statement in db.php and next was called another /pdo/db.php. It calls /wp-includes/wp-db.php. There it stops.
Adam
@Adam Baron:
there is no error there.
what version of wordpress are you using? and what version of the plugin?
i have had some problems with the svn upload to wordpress.org and it may be that the upload is still corrupted or that the wrong versions of the files are being made available.
I have downloaded form web:
wordpress latest 2.7.1
pdo for wordpress 2.5.0
im getting this error:
“Invalid or missing PDO Driver”
i’m using the last version of wordpress and pdo
and.. print_r(PDO::getAvailableDrivers()); gimme it:
Array ( [0] => mysql [1] => pgsql )
[off] in wp-config.php, the login, pass and host name are required or i can delete it?
@Heric:
this simply means that you don’t have the sqlite driver for PDO installed. have a look at the php manual for how to install it. assuming you are using linux the easiest way is to use PECL
i think is a problem with permisson, because in localhost it works, what archives i need to change permisson?
… let me try, if the host dont have support for pdo i will do a suicide >.>
@Heric:
It is nothing to do with permissions. the error is only displayed if you do not have the right PDO extension loaded.
Pretty interesting project! I really would like this to work on my synology cs407. I ipkg-ed a lighttpd on it and php
I get the “Invalid or missing PDO Driver” error and the line as above + Array ( [0] => sqlite2 [1] => sqlite ) + define(‘DB_COLLATE’, ”); define(‘DB_TYPE’, ‘sqlite’); //mysql or sqlite
So … hmmm.. what did I miss… probably something stupid
ok… so i disabled one of the sqlite extension and it runs through… now…. a blank screen! exciting!
hmmm it fails on require_once ABSPATH.’wp-includes/wp-db.php’;
So i commented the $wpdb line in wp_db and now it generates such a huge amount of errors… but it creates a “MyBlog.sqlite”. it boils down to “Error occurred at line 350 in Function prepareQuery.
Error message was: Problem preparing the PDO SQL Statement. Error was Array ( [0] => HY000 [1] => 1 [2] => near “,”: syntax error ) “
@Edward de Leau:
this is an issue with wp 2.8.0 and the change in database inserts that is used during the install process.
i have written a fix which i will upload later today.
Thanks Justin!
It works perfectly Justin, thanks very much!
@Edward de Leau:
no worries.
I’ve run into some problems with the pluggin install. When I follow the standard install instructions I get the following error:
Mon Jun 01 21:07:33 2009] [error] [client 192.168.10.11] PHP Fatal error: Uncaught exception ‘PDOException’ with message ‘SQLSTATE[HY000] [14] unable to open database file’ in /export/home/jlhuber/httpd/blog/wp-content/pdo/PDOEngine.php:111\nStack trace:\n#0 /export/home/jlhuber/httpd/blog/wp-content/pdo/PDOEngine.php(111): PDO->__construct(‘sqlite:/export/…’)\n#1 /export/home/jlhuber/httpd/blog/wp-content/pdo/PDOEngine.php(53): PDO_Engine->connect(Array)\n#2 /export/home/jlhuber/httpd/blog/wp-content/pdo/db.php(95): PDO_Engine->PDO_Engine(Array)\n#3 /export/home/jlhuber/httpd/blog/wp-content/pdo/db.php(76): pdo_db->createDBObject()\n#4 /export/home/jlhuber/httpd/blog/wp-content/pdo/db.php(234): pdo_db->pdo_db(‘jlhuber’, ‘nomatter’, ‘/export/home/jl…’, ‘localhost’, ‘sqlite’)\n#5 /export/home/jlhuber/httpd/blog/wp-content/db.php(140): require_once(‘/export/home/jl…’)\n#6 /export/home/jlhuber/httpd/blog/wp-includes/functions.php(2537): require_once(‘/export/home/jl…’)\n#7 /export/home/jlhuber/httpd/blog/wp-settings.php(250): require_wp_db()\n#8 /export/home/jlhuber/httpd/blog/wp-config in /export/home/jlhuber/httpd/blog/wp-content/pdo/PDOEngine.php on line 111
I saw a post that suggested I create the database myself and change the permissions to 777 on the database folder and database. When I do this I get this error:
PHP Fatal error: Call to a member function bail() on a non-object in /export/home/jlhuber/httpd/blog/wp-content/pdo/PDOEngine.php on line 77
Thanks in advance for any help with this.
Thanks for the great plugin!
I just installed it on my blog, and tested it briefly, and everything seems to be working.
However, when I tried to import the content from my old blog (wordpress XML export), I get a
Fatal error: Call to a member function execute() on a non-object in /data/cyberfish/website/blog/wp-content/pdo/PDOEngine.php on line 489
Is there a way to get around that?
Many thanks!
(I can email you the XML dump if that’s needed)
ps. It’s a new installation of WordPress 2.7.1
Plugin version 2.6.0
Hi Cyberfish
i have never tried an export/import. i would be interested in doing so. So yes – please do send me the xml dump. You can upload to http://www.adieandco.com/uploads
thanks
Justin
Hello Joshua
The error looks to be caused by permissions. I ought to put the connection code in a try … catch block but typically the permissions issue should be caught in the installation process.
the error that you report is indicative that you are using an older version of the plugin. Try downloading the latest version from wp.org. The current version is 2.6.0.
If you still get a problem then I suggest you do the following
1. delete the wp-content/database folder (or rename it).
2. make sure that the wp-content folder has got 0777 permissions on it and inherited objects (you can change them back later)
3. rerun the installation.
4. change back the perms as you want.
@Justin,
Thanks!
Dump uploaded (wordpress.2009-06-02.xml.zip, unzips to about 1MB)
It works! thanks.
@Justin,
any update? =)
Hi Justin,
name mismatch ?
version 2.6.0
pdo_sqlite_driver.php
case “optimize”: $this->rewrite_optimize();
private function rewriteOptimize(){
…
}
@fnumatic,
Thanks Ulf. Good spot. Fixed in version 2.6.1 (to be uploaded later today)
@cyberfish,
sure. i just tried your xml file with a new code version and it imported 11 posts with 671 comments, of which 590 were spam. does that sound right?
i got quite a few errors in the install process, but the same errors appeared in the mysql alternative I ran. They are thrown as warnings so would not normally be visible.
version 2.6.1 will be posted later today.
@Justin,
Hmm there should be 24 posts, but I’ll give the new version a try.
Thanks!
@Justin,
The new version finishes the import without errors, but only imports 10 posts (I have 24 in the dump). Not sure why.
@cyberfish,
i got a bunch of warnings about implode being given the wrong number of arguments. try turning on error_display and error_reporting to see them.
but these were not PDO errors, the backtrace contained no references to database calls so structurally i assume that these errors come from inconsistencies in the export/import process.
Personally, I’m not sure whether there is a good reason for WordPress to have selected an xml export/import feature when SQL is right there. Probably it is to maintain compatibility with other blogging tools. If you want to go WP->WP, whatever the database flavour, I’d recommend using SQL. You could knock up a migration plugin in a few minutes, I’m sure. Or just use phpmyadmin to grab the SQL dump.
Im not quite sure but merging (EDIT) comments gives: Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /volume1/web/cogmios/wp-includes/comment.php on line 1093
@Justin,
Thanks!
I have made a SQL dump with phpmyadmin. How do I import it into the sqlite database?
@Edward de Leau, that does not sound like a database problem. More likely something wrong with whatever plugin you are using to merge comments.
i have found that WP comes up with a lot of E_NOTICE and E_WARNING messages and it’s best to keep error_reporting turned off unless debugging.
Hi, Justin. I’m a Japanese. Excuse my poor English.
I’m trying WP 2.7.1 and 2.8 with PDO-SQLite 2.6.0 and 2.6.1 on XAMPP 1.7.0.
I have a problem that the first ‘Hello world!’ cannot be found in the archives.
That is like the problem ‘oursolo’ said.
WP compares MONTH() with varied form values like ’6′, ’06′ or 6.
However http://www.sqlite.org/datatype3.html says:
An INTEGER or REAL value is less than any TEXT or BLOB value,
and http://www.sqlite.org/lang_datefunc.html says that
strftime() substitution %m returns 01-12.
So the type-mismatch or missing the leading zero fails the query.
I have hacked and fixed pdo_sqlite_driver.php ad-hoc like this:
private function rewrite_datetime_functions(){
$pattern = ‘/\b(year|month|day|dayofmonth|unix_timestamp)\s*\((.*?)\)(?:(\s*=\s*)\’(\d+)\’)?/imx’;
$query = preg_replace_callback($pattern, array($this, ‘_rewrite_datetime_functions’), $this->_query);
$this->_query = $query;
}
private function _rewrite_datetime_functions($matches){
switch (strtolower($matches[1])){
case “year”:
$replaced = “CAST(strftime(‘%Y’,{$matches[2]}) AS INTEGER)”;
break;
case “month”:
$replaced = “CAST(strftime(‘%m’,{$matches[2]}) AS INTEGER)”;
break;
case “day”:
case “dayofmonth”:
$replaced = “CAST(strftime(‘%d’,{$matches[2]}) AS INTEGER)”;
break;
case “unix_timestamp”:
$replaced = “CAST(strftime(‘%s’,{$matches[2]}) AS INTEGER)”;
break;
}
if (!empty($matches[3])){
$replaced .= $matches[3] . $matches[4];
}
return $replaced;
}
@Justin,
BTW, it appears like (like you have pointed out) it’s not a PDO problem. People are having this problem with MySQL, too.
http://wordpress.org/support/topic/204493
@cyberfish, that’s outside the scope of the plugin. i suggest some software like sqlitemyadmin, sqlitemanager or the like.
or write your own code. essentially all you need to do is mirror what i do in the installation routine (capture the sql, and shove it into the the sql rewriter on a query by query basis.
@usdesign,
i took a design decision not to cast year to integer as i was not sure when two digit years may be made.
otherwise the casting was included in my code at version 2.6.0
i have seen that you have tweaked the regex but i cannot work out what advantage that might give? can you clarify?
to my mind we need to deal with several use cases. as follows:
select 5=’05′ must give true
select 5=5 must give true
select 5=’5′ must give true
select 5=05 must give true
results on non casted values are as follows:
1. false;
2. true;
3. false;
4. true;
but by forcing the cast as per my code:
@usdesign,
i took a design decision not to cast year to integer as i was not sure when two digit years may be made.
otherwise the casting was included in my code at version 2.6.0
i have seen that you have tweaked the regex but i cannot work out what advantage that might give? can you clarify?
to my mind we need to deal with several use cases. as follows:
select cast(5 as int) =’05′ gives true
select cast(5 as int)=5 gives true
select cast(5 as int)=’5′ gives true
select cast(5 as int)=05 gives true
essentially the sqlite parser also performs a cast on the operand.
@Justin,
I investigated into this a bit, and it appears like MySQL -> SQLite conversion is a huge pond of mud. I have tried many “conversion scripts”, and non seems to work.
Guess I will have to stick to MySQL, then, until WordPress fixes XML import/export.
Thanks for your great work!
@cyberfish
curious. my plugin does the conversion for you. why are you looking for another conversion script? feel free to upload the sql dump and i will convert it to sqlite when i can.
My intention is to force integer comparision.
My fixed code works correctly on XAMPP 1.7.0, but original code does not.
I had also cheked with SQLite Database Browser 1.3 on WinXP.
http://sqlitebrowser.sourceforge.net/
Hm… is that dependently SQLite version or platform?
@Justin,
Ah! I never knew the plugin does the conversion. But how?
It doesn’t appear in the plugin page. I tried following the instructions in the readme from my existing installation, and my posts aren’t imported.
I don’t think the readme file mentions this, either.
Thanks
inconsistent language, i think. my plugin is not a real plugin in that it does not sit in the plugin list. WP has always provided a hook for developers to use alternative database systems though. this is what i am using.
you cannot simply point your sql dump at my code and say go. but the core of my code takes a mysql query and rewrites into in language that sqlite can understand. so you can use the query rewriter to parse the sqldump for you.
alternatively, send through the dump and i will send back a sqlite database.
i have tested on windows, mac and linux boxes and confirm that the regex that i had together with casting to INT (which is a synonym for integer) correctly fixed the problem.
i cannot judge as to why the code does not work for you. casting and comparisons are such basic functionality that i think it unlikely to be a sqlite library issue.
Ah I see.
Am I right to assume that it’s not exposed to the user?
(sorry I don’t know much about SQL)
SQL dump uploaded.
Many thanks!
Thanks Justin, and cyberfish.
I will investigate it a little more and contact you again if I have found the cause.
I wasn’t replying to your comment, but to my own problem :).
I am new to WP. The topic that you, cyberfish, pointed out is curious.
That just appear replying me, and it is my misread?
Excuse me…
Hi a bug i got this message :
with this code
I found the problem is when using thre print_r statement to write information debug2.txt
from :
global $wp_query;
$curauth = $wp_query->get_queried_object();
or :
if(get_query_var(‘author_name’)) :
$curauth = get_userdatabylogin(get_query_var(‘author_name’));
else :
$curauth = get_userdata(get_query_var(‘author’));
endif;
may be an ob_start somewhere else in the api
commenting the line with print_r solve the problem
? I upgraded to 2.8 (copied 2.8 files into my synology dir) but not I get a blank screen. when i remove the pdo dir it obv. says i need mysql.
but … i commented the last line in wp-db.php again and it works again
Hello,
My server uses PHP 4.4.8. I tried to work with WP 2.6.2 with your plugin but I cannot establish a database connection. I suppose that there is a version mismatch. Which version of your plugin would support PHP4.4.8 and WP2.6.2?
Thank you!
which line is that?
Hi Ana
the plugin is primarily designed to enable the use of the PDO abstraction layer. the first ‘driver’ for the PDO abstraction layer that i have written is sqlite.
PDO is not available for versions of php < 5.0. Because of this i took a design decision with the plugin to code in an object oriented style that is not compatible with php 4.x. SFAIK there are very few active installations on php 4.x and those that exist are to maintain existing websites that might break if upgraded. Are you able to upgrade to php 5? you might want to investigate this anyway as php 6 is not far away now. Justin