当前位置:
首页 > 技术站长 > PDO (SQLite) For WordPress

PDO (SQLite) For WordPress

This 'plugin' enables WP to use databases supported by PHP's PDO abstraction layer. Currently, mysql and sqlite drivers are provided.

Download Version 2.7.0

PDO (SQLite) For WordPress

Description

WordPress has for a long time, and for good reasons, been locked into using mysql as its database storage engine. There is a good discussion of 'why' in the codex

But this design choice has ramifications; not least because mysql's implementation of sql is not standard. Even with the use of the EZSQL abstraction layer bundled with WordPress, this makes plugging in other databases very difficult.

PDO For WordPress is a step towards eliminating this difficulty. Think about this 'plugin' in four steps:

the basic layer takes all queries and separates out the variables from the language. It replaces each variable with a placeholder as well as stripping mysql specific 'nasties' like the slash-escaping and backticks.
then a language specific driver steps in and rewrites the query to use its own native constructs or (in the case of SQLite) pushes the query into some special user-defined functions
the basic layer then puts it all back together and runs the query, finally ...
returning the whole thing to the EZSQL abstraction layer so that WordPress doesn't know that anything has gone awry
See below/other notes for details of known limitations

Installation

This plugin is not a simple WordPress plugin. Beware. You cannot just put the files in plugins and enable through the control panel. This is because the database needs to be connected adn established BEFORE the plugins are loaded.

So ... to install PDO For WordPress please do the following:

Step 1: unzip the files in your wp-content directory. After unzipping the structure should look like this

wp-content
->plugins
->themes
->pdo
db.php
index.php[maybe]

The key thing is the presence of the pdo directory and the db.php file in the 'root' of the wp-content directory.

Step 2: Edit your wp-config.php file so that:

this line of code is placed directly after the define('COLLATE',''); line:

define('DB_TYPE', 'sqlite'); //mysql or sqlite`
Note: currently only mysql and sqlite are supported. I hope that more flavours will appear soon.

As part of the general wordpress installation you should define your secret keys too (in wp-config.php).

and that's it. two steps.

The next time you load your wordpress installation it will automatically create the database and take you through the basic WordPress installation routine. If you have problems with the installation you should receive a meaningful error messsage. If not, the most common error by far is permissions. You MUST make sure that php can read/write to wp-content/database.

(PDO (SQLite) For WordPress — WordPress Plugins
https://wordpress.org/plugins/pdo-for-wordpress/)

PDO (SQLite) For WordPress:等您坐沙发呢!

发表评论

您必须 [ 登录 ] 才能发表留言!