PDO For WordPress and WP > 2.8
it’s been a while since i have had time to update PDO For WordPress.
i have had a preliminary look at things and i believe that the incompatibility for new installs is based in the is_blog_installed() function. this should be fixable but is non-trivial.
for existing installs, the fix should be trivial (indeed, I am typing here on wp2.9 with PDO For WordPress 2.6.1 – i get some errors but nothing fatal).
i am hoping to have a full fix uploaded in the next week.
December 27th, 2009 in
PDO For Wordpress
Hi. I use your briliant plugin on my seo installation with hundreds of blogs. Bassicaly in my routine i a install blog, send about 200 posts, and set as draft planned for later publication
Everything was more than good, was hilarious
until i found out that in few blogs after some time im getting that kind of error:
Queries made or created this session were
1. Raw query: UPDATE wp_posts SET post_status = ‘publish’ WHERE ID = 12
2. Rewritten: UPDATE wp_posts SET post_status = ‘publish’ WHERE ID = 12
3. With Placeholders: UPDATE wp_posts SET post_status = ? WHERE ID = 12
4. Prepare: UPDATE wp_posts SET post_status = ? WHERE ID = 12
5. Executing: Array ( [0] => publish )
Error occurred at line 459 in Function executeQuery.
Error message was: Error executing query. Error was was database disk image is malformed
PDO_Engine Object
(
[isError] =>
[foundRowsResult] =>
[initialQuery:private] => UPDATE wp_posts SET post_status = ‘publish’ WHERE ID = 12
[rewrittenQuery:private] => UPDATE wp_posts SET post_status = ‘publish’ WHERE ID = 12
[queryType:private] => update
[rewriteEngine:private] => pdo_sqlite_driver Object
(
[ifStatements:private] => Array
(
)
[startingQuery:private] => UPDATE wp_posts SET post_status = ‘publish’ WHERE ID = 12
[_query] => UPDATE wp_posts SET post_status = ‘publish’ WHERE ID = 12
[dateRewrites:private] => Array
(
)
[queryType] => update
)
[needsPostProcessing:private] => 1
[results:private] => Array
(
)
[pdo:private] => PDO Object
(
)
[preparedQuery:private] => UPDATE wp_posts SET post_status = ? WHERE ID = 12
[extractedVariables:private] => Array
(
[0] => publish
)
[errorMessages:private] => Array
(
)
[errors:private] => Array
(
[0] => Array
(
[line] => 459
[function] => executeQuery
)
[1] => Array
(
[line] => 459
[function] => executeQuery
)
[2] => Array
(
[line] => 459
[function] => executeQuery
)
[3] => Array
(
[line] => 459
[function] => executeQuery
)
[4] => Array
(
[line] => 459
[function] => executeQuery
)
[5] => Array
(
[line] => 459
[function] => executeQuery
)
[6] => Array
(
[line] => 459
[function] => executeQuery
)
[7] => Array
(
[line] => 459
[function] => executeQuery
)
)
[queries] => Array
(
[0] => Raw query: UPDATE wp_posts SET post_status = ‘publish’ WHERE ID = 12
[1] => Rewritten: UPDATE wp_posts SET post_status = ‘publish’ WHERE ID = 12
[2] => With Placeholders: UPDATE wp_posts SET post_status = ? WHERE ID = 12
[3] => Prepare: UPDATE wp_posts SET post_status = ? WHERE ID = 12
[4] => Executing: Array
(
[0] => publish
)
)
[dbType:private] => sqlite
[lastInsertID:private] =>
[affectedRows:private] =>
[columnNames:private] => Array
(
)
[numRows:private] =>
[returnValue:private] =>
[startTime:private] =>
[stopTime:private] =>
[_results] => Array
(
)
[statement] => PDOStatement Object
(
[queryString] => UPDATE wp_posts SET post_status = ? WHERE ID = 12
)
)
Do u have any idea how to get this fixed or prevent it in any way in the future?
Thanks a lot for great plugin and ur work
Sincerly
Hi
you should try running a vacuum on the database. from the reported error your database has become corrupted due to a file-system problem. potentially a power cut or server crash could cause this.
Hi.
Thanks Justin im gonna try this and then let u know is that work, for future readers.
PDO For WordPress 2.7.0 has now been uploaded to WP.org. It is (should be) compatible with 2.9.1 and below.
Hello. Sorry for my english)) I find a small, but very bad bug. When WP working with sqlite, dont showing navigation in categories and tags pages. May be my information will be interesting. If look result of query in wp-includes\query.php on line 2276
$this->found_posts = $wpdb->get_var( $found_posts_query );
in mysql version showing really posts amount, but in sqlite version only one. May be this trouble will fixed in next versions of plugin?
I will take a look. I am assuming that you are using version 2.7.0 of the plugin.
the latest version of wordpress starts using a lot of mysql specific functions; which is a terrible idea for portability. I have also found other bugs that require fixing (for example with role_scoper).
can you send your wp-content/database/debug.txt file to me to check the offending query? best if you delete the file, run the commands that you think produce the wrong results, and then send the newly generated file through. jpadie@gmail.com.
I am having a couple of issues with the plugin, one which I reported with the earlier version. If you have the characters “)”, without the “” around the ) in a post it can not be edited. The error is – “Fatal error: Maximum execution time of 30 seconds exceeded in ***\***\blog\wp-includes\plugin.php on line 302 Importing articles that have the “)”, in the post do not import either. Also, the links section does not work correctly. The edit links section does not show any links. Links can be added, but they do not appear. The WP install is 2.8.5 and the pdo plugin was upgraded from 2.6.1. Thanks for the plugin and all of your work.
As a note, if I post a comment on this site with “)”, without the “” in the comment I get the following error – “Error 404 – Not Found” from the link http://rathercurious.net/comment-page-#comment-
you are right. I noticed this in a recent post myself just after I upgraded to wp2.9.1 + plugin 2.7.0. i am part way through a fix but actually it’s more complex than it should be … because of recursion, you can’t use pattern matching to extract variables from queries. i am working on a parser method instead. not straightforward at all.
I can’t seem to get this to work on my server. The error I receive is:
Your PHP installation appears to be missing the PDO extension which is required for this version of WordPress.
This is supposed to make wordpress work even though my server doesn’t have MySQL, right?
Hi Chris
You are correct that with this plugin you are able to use wordpress on a server installation that does not have MySQL.
Of course you still need PDO and the PDO_SQLITE extensions.
PDO is an abstraction layer that is shipped with PHP and allows PHP to talk to a bunch of different databases using the same commands.
PDO_SQLITE is the library that allows PDO to talk to SQLite databases. Similar ‘drivers’ exist for many other databases.
You should check your phpinfo() and your server to determine whether PDO and PDO_SQLITE are installed (but from the error message it seems that they are not). Your server admin should be able to do the necessary for you.
Justin,
1. Thank you for the hard work. Great plugin.
2. New WP 2.9.1 + PDO 2.7 setup. Receive following error during WP installation:
http://example.com/wp-admin/setup-config.php?step=2
Invalid or missing PHP Extensions.
Your PHP installation appears to be missing the PDO extension which is required for this version of WordPress.
Troubleshooting:
php -v reports PHP version 5.2.12.
php -m reports PDO and PDO_SQLITE modules installed.
db.php and pdo/ are in wp-content
added define(‘DB_TYPE’, ‘sqlite’); to wp-config-sample.php
wp-content is chmod -R 777
What am I missing? Thanks.
Like this plugin.
Could you answer a few questions please?
1. I think running wordpress on sqlite is faster than mysql, at least for small to medium sites. Is it correct?
2. Right now I am using some plugins that shows in the widgets the “most viewed posts”, “related posts” etc. However, after using sqlite backend, these functions stopped working. Is there any way to fix it? For example, this one: http://wordpress.org/extend/plugins/efficient-related-posts/
@Joseph
Hi Joseph
this message means that you have not loaded the relevant PDO extensions in your installation of php. check out the manual at php.net/pdo for the installation steps.
@tw
1. sqlite is not great in multi-access environments. and a full answer to your question would need to take account of the latency between your mysql server and your webserver.
however, a low-medium traffic site should do as well using sqlite if not better than mysql
but this is not the case with my extension and WP because you have to take into account the overhead of recasting the queries to sqlite lingo rather than mysql. this will almost certainly render the site slower. sqlite does some funky cacheing though. the first page load might take a while but subsequent pages should be pretty zippy.
2. if a plugin does not use the wp-db abstraction layer then my plugin will not be able to handle it. it’s bad coding on the part of the plugin author (and by bad I mean non-standards compliant rather than anything qualitative).
I do not know what the specific issue might be with this plugin. a brief glance at the code suggests that it does use the abstraction layer when needed. are you getting error messages?
I am sort of newish at the whole database system…However I am trying to move from mySQL -> Microsoft SQL server and found this plugin. I have gotten it to the point where it asks me to install it. I put my “blog title” etc and it says that it installed correctly and give me the “password” and when I click “login” with my new auto-generated pwd and “admin” it goes back to the “install.php” screen. It is an endless loop of installs and re-installs.
I have followed every tip I have seen so far. I am wondering if I have just missed something simple. I have changed all the permissions etc. Any help would be greatly appreciated.
Thanks for the plugin so far.
Hi
if i follow your comment correctly, you are trying to use WP with an MS sql server back end. whilst it is technically possible to use PDO with MS Sql server, you will need to create a driver for use with the PDO For WordPress plugin, that supports MS SQL Server. I have not developed one. I have a version that a user of my plugin has developed but I have never tested it so cannot vouchsafe that it works.
Thank you for your response…do you have a link to the other users plugin? I would love to try it out…we have a dev server and I would love to get my head around this. Thanks
I don’t think that he ever published it.
it was not a plugin as such but a first stab of an MS Sql driver for my plugin.
unless you are a database guru, i would counsel against MS Sql. Apart from the fact that it is terrifyingly expensive and needs a heavyweight server to power it, why would you want it to power a simple blog?
if you can run mysql then i’d stay with it. if you want the benefits of an encapsulated system like sqlite, then most probably your php installation already supports it. all you need to do is set the DB_TYPE definition to ‘sqlite’ and everything should work.
i keep promising to have a go porting to mssql but inertia always defeats me. I don’t have a windows system to test on, nor do I have ms sql (although i guess i could use sql express or whatever the free version is called). there are several inconsistencies with sql ansi that would annoy me and, regrettably, the client libraries for php< ->mssql are really not great. very buggy with big fields. could get around it, perhaps, with odbc but then the odbc client libraries are hardly paragons of virtue themselves…
looking forward to hearing why you want ms sql.
Well here is the situation, hopefully you can understand it: Right now I am working on automating wordpress -> meaning when I click “install” in our software it runs a script which buys a domain, installs wordpress, sets up database and sets up our customization. Right now it works great and we use a XML feed to implement our data for each site for our customers.
As of right now we are using an XML website that was created (not on wordpress) But we would like to use wordpress because it will allow our customers to create blogs for themselves if they like. We get about 20-30 new customers a day.
This is where the problem comes in: the database we use right now for all of our customers is based in MS SQL and we have been running it for 6-7 years so we aren’t about to change it. But we want to use all of our variable such as (@businessname etc) for our database instead of XML feeds – faster, easier to maintain etc.
Therefore the biggest reason I want to get wordpress on MS SQL is so that we can use our current database with wordpress without having to move it to MYSQL (which won’t happen). We also would rather use a database instead of XML feeds.
Hopefully this helps you out. Currently my system works but we have to maintain 2 databases (MYSQL and MS SQL) and have to use XML feeds instead of database variables. Any suggestions on how to make this situation would be greatly appreciated. Thanks
@Justin
* Which are the relevant PDO extensions?
* How does one verify they’re loaded?
Thanks.
Joseph
in order to use PDO_SQLITE you need the pdo library and the pdo_sqlite library.
different platforms load these in different manners as is normal for php.
You can find more about them here: http://fr.php.net/manual/en/pdo.installation.php
you can verify whether they are loaded by examining the output of phpinfo()
@Justin
phpinfo() reports pdo and pdo_sqlite are loaded:
PDO
PDO support: enabled
PDO drivers: sqlite, mysql, sqlite2
pdo_sqlite
PDO Driver for SQLite 3.x: enabled
PECL Module version (bundled) 1.0.1 $Id: pdo_sqlite.c 272374 2008-12-31 11:17:49Z sebastian $
SQLite Library: 3.3.7