Hi,
It seems after upgrading to PHP 7.2, error logs are filled with this warning:
PHP Warning: count(): Parameter must be an array or an object that implements Countable in /wp-content/plugins/wp-db-driver/inc/db-driver.php on line 1684
Please advise if there is a fix.
Thanks
]]>It more likely fails with the upcoming 4.9
]]>Any plans to continue development, in order to support replication, failover, load balancing, & partitioning?
https://github.com/stuttter/ludicrousdb
Not using ludicrousdb because it doesn’t support the PDO.
Can’t use both at the same time.
]]>PDOException SQLSTATE[HY000]: General error – /wp-content/plugins/wp-db-driver/drivers/pdo_mysql.php:277
#12 /wp-content/plugins/wp-db-driver/inc/db-driver.php:1687 – wpdb_driver_pdo_mysql->get_results()
#11 /wp-content/plugins/wp-db-driver/inc/db-driver.php:1891 – wpdb_drivers->query(‘UPDATE `
wp_opt…’)
#10 /wp-includes/option.php:333 – wpdb_drivers->update(‘wp_options’, Array[2], Array[1])
#9 /wp-includes/option.php:1459 – update_option(‘_site_transien…’, stdClass, ‘no’)
#8 /wp-includes/option.php:1067 – update_network_option(1, ‘_site_transien…’, stdClass)
#7 /wp-includes/option.php:1682 – update_site_option(‘_site_transien…’, stdClass)
#6 /wp-includes/update.php:268 – set_site_transient(‘update_plugins…’, stdClass)
#5 /wp-includes/class-wp-hook.php:298 – wp_update_plugins(”)
#4 /wp-includes/class-wp-hook.php:323 – WP_Hook->apply_filters(”, Array[1])
#3 /wp-includes/plugin.php:453 – WP_Hook->do_action(Array[1])
#2 /wp-admin/admin.php:329 – do_action(‘load-plugins.p…’)
#1 /wp-admin/plugins.php:10 – require_once(‘/var/www/auno….’)
Hi! Plugin not worked
Ubuntu 16.4
PHP 7.0.7
MySQL 5.7.
I am using WordPress 3.9.2 with php 7.0 and trying to use WP DB Driver 2.1.0 is this works?
If not then please give suggestion to me on this.
Also how to test WP DB Driver for PDO?
Thanks,
Nilesh P
For a clean WordPress setup where the admin dashboard is not available to activate the plugin with a GUI one needs to copy files manually.
I did not understand how to make the plugin driver to work.
Steps are
1. Extract the wp-db-driver.2.1.0.zip
2. copy directory wp-db-driver into the ./wp-content/plugins/
3. copy ./wp-content/plugins/wp-db-driver/db.php to ./wp-content/db.php
4. Run the wordpress installer
I had hard time figuring this out. So i write this short manual
how to copy this manually.
Recently moved site to a new server running PHP 7.0.7 – site generally works, but seeing the following errors in the logs from the wp-cron task:
2016/06/12 01:11:42 [error] 3128#3128: *642 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error in /srv/www/example.com/wp-content/plugins/wp-db-driver/drivers/pdo_mysql.php:277
Stack trace:
#0 /srv/www/example.com/wp-content/plugins/wp-db-driver/drivers/pdo_mysql.php(277): PDOStatement->fetchObject()
#1 /srv/www/example.com/wp-content/plugins/wp-db-driver/inc/db-driver.php(1687): wpdb_driver_pdo_mysql->get_results()
#2 /srv/www/example.com/wp-content/plugins/wp-db-driver/inc/db-driver.php(1891): wpdb_drivers->query('UPDATE 'wp_opti...')
#3 /srv/www/example.com/wp-includes/option.php(328): wpdb_drivers->update('wp_options', Array, Array)
#4 /srv/www/example.com/wp-includes/cron.php(464): update_option('cron', Array)
#5 /srv/www/example.com/wp-includes/cron.php(101): _set_cron_array(Array)
#6 /srv/www/example.com/wp-includes/cron.php(147): wp_schedule_event(1465693991, 'nxsreposter', 'nxs_querypost_e...', Array)
#7 /srv/www/example.com/wp-cron.php(103): wp_reschedule_event(14656939" while reading response header from upstream, client: 2400:8900:xxx:xxx::100, server: www.example.com, request: "POST /wp-cron.php?doing_wp_cron=1465693902.3811419010162353515625 HTTP/1.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "www.example.com"
(I’ve replaced the domain names with example.com)
]]>Hi! Please fix plugin for php703 and MySQL 5.7
]]>I do not understand what does this plugin do. What do I need to do with this plugin to make my wordpress website work better? faster? w/e?
I have working wp website. And I have cpanel. What do I do now with this plugin?
PLease write steps on what to do.
Do I need to change something here: https://prntscr.com/9by345
??
Thanks
]]>Hi,
Added PDO driver using plugin, all looks good, https://snag.gy/TEzoU.jpg
php.error.log showed the following when driver added:
[11-Nov-2015 17:44:27 UTC] PHP Fatal error: Class ‘WP_DB_Driver_Config’ not found in /srv/users/serverpilot/apps/shop/public/wp-content/plugins/wp-db-driver/wp-db-driver.php on line 203
[11-Nov-2015 17:49:29 UTC] PHP Fatal error: Class ‘WP_DB_Driver_Config’ not found in /srv/users/serverpilot/apps/shop/public/wp-content/plugins/wp-db-driver/wp-db-driver.php on line 159
No further errors subsequently.
Cheers,
Phil
Your include statements from line 4 and 5 in plugins/wp-db-driver/inc/db-driver.php are wrong:
require( dirname( __FILE__ ) . '/inc/error-handler.php' );
require( dirname( __FILE__ ) . '/inc/interface-wp-db-driver.php' );
There’s no other inc directory in inc. Result is a fatal error:
Warning: require(/var/www/wordpress/wp-content/plugins/wp-db-driver/inc/inc/error-handler.php): failed to open stream: No such file or directory in /var/www/wordpress/wp-content/plugins/wp-db-driver/inc/db-driver.php on line 5 Fatal error: require(): Failed opening required '/var/www/wordpress/wp-content/plugins/wp-db-driver/inc/inc/error-handler.php' (include_path='.:/usr/local/lib/php') in /var/www/wordpress/wp-content/plugins/wp-db-driver/inc/db-driver.php on line 5
]]>
Hello,
Just to be sure, normally with PDO, we can use any database (thanks to drivers).
But :
You can specify pdo_mysql, mysqli, or mysql. Any other driver will cause an error.
It means if I use the plugin with a Postgres, MSSQL or Oracle database, it won’t work ???
Thank you.
]]>Some silly plugins actually check or enforce that $wpdb
is an instance of the wpdb
class, which does kind of make sense if you prefer strict code. But in the case of WP DB Driver, $wpdb
is set to an instance of the wpdb_drivers
class, so this test fails.
These checks could be in the form of:
function my_func(wpdb $wpdb) {
...
}
Or just:
if ($wpdb instanceof wpdb) {
...
}
To circumvent this, wouldn’t it be a good idea to extend the wpdb_drivers
class from the wpdb
class? This would solve any issues like this with other plugins, and also make it more semantic.
What do you think?
]]>I tried to update this plugin to the last version.
It replaces all the special characters with weird symbols, everywhere (Backoffice, front end, etc…) Reverted back to 1.8.1
]]>Hi!
I’m very interested in your plugin, it seems amazing! The only problem (and it’s a quick question) is where am I suppose to put my PDO statement?
I mean this line :
$stmt = $dbh = new PDO(“mysql:host=$NomHost; dbname=$NomBD”, “$NomUser” , “”) ;
Where is it supposed to go? I have an otherp lugin to put PHP code in a WP page, but it doesn’t seem to work…
Thank you for helping me!
]]>I was just reading this Codex article regarding using alternative databases and their answer was pretty much “it’s not possible right now”. Yet here we have this awesome plugin which seems to make it work!
Is this really a full replacement for the $wpdb object?
https://codex.www.ads-software.com/Using_Alternative_Databases
https://www.ads-software.com/plugins/wp-db-driver/
PS. Have you considered creating an SQLite adapter? Are there any roadblocks?
]]>Greetings,
I’ve installed WP DB Driver according to the provided instructions.
I’ve added define( 'WPDB_DRIVER', 'pdo_mysql' );
to my wp-config.php.
I’ve copied db.php to WordPress installation directory and wp-content/dp.php to the WordPress wp-content directory.
I have a functions.php in my child theme with the following function:
function twentytwelve_child_build_glossary(){
// Create PDO
$dbh = new PDO(DB_HOST, DB_USER, DB_PASSWORD);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$strSQL = "SELECT term, definition FROM <code>wp_glossary</code> ORDER BY term";
try {
// Prepare sql statement
$stmt = $dbh->prepare($strSQL);
$stmt->execute();
$result = $stmt->fetchAll();
} catch (Exception $e) {
$result = "PDO Failed with Error: $e";
}
return $result;
}
I use an added shortcode to trigger the function, if that makes any difference.
I get the following error when attempting to use the function:
“Fatal error: Uncaught exception ‘PDOException’ with message ‘could not find driver’ in C:\xampp\htdocs\EOD\wp\wp-content\themes\twentytwelve-child\functions.php:15”
Any idea what the issue might be.
Thanks!
]]>After update to 1.9 my WordPress shows bad characters for all non ASCII characters, on front and in admin.
I use PDO, UTF-8 and nb_NO on a multisite.
When db driver is removed from Settings, all is fine.
Do you need me to test something, just ask.
]]>define( 'WPDB_DRIVER', 'pdo_mysql' );
is actually define( 'WPDB_DRIVER', 'PDO' );
Strict Standards: Declaration of wpdb_drivers::db_connect() should be compatible with wpdb::db_connect($allow_bail = true) in /var/www/c-d-h.fr/server/wp-content/plugins/wp-db-driver/db.php on line 344
Thank you for thsi driver!
Could you copy those lines from 3.9?
]]>What I would like is for a method in the wpdb_drivers class that looks something like this:
public function getDbh()
{
return $this->dbh;
}
This would allow me to use features not supported such as transactions and stored procedures. This way wordpress can do its stuff using the wpdb_drivers class while I have the freedom to do whatever the database supports without having to resort to an additional database connection.
Any thoughts on this?
]]>A patch to fix this issue is available at
https://github.com/markmont/wp-db-driver/commit/411f128d977801a6cacde97d1314825f9a22193a
wb-db-driver 1.5, WordPress 3.6, PHP version 5.5.1, PDO driver, MariaDB version 5.5.31.
Some queries (anything other than create, alter, truncate, drop, insert, delete, update, replace
) may return the wrong number of rows. Example:
global $wpdb;
$table_name = $wbdp->prefix . 'posts';
if( ! $wpdb->query( "SHOW TABLES LIKE '{$table_name}';" ) ) {
error_log( "Oh no, the WordPress posts table, ${table_name}, does not exist!" );
} else {
error_log( "All is well." );
}
When run, the above code will claim that the posts table does not exist, even though it does exist. This is a real-world test case from a plugin that fails to work with wp-db-driver, the Wysija Newsletters plugin, see lines 495-497 of
https://plugins.trac.www.ads-software.com/browser/wysija-newsletters/trunk/helpers/install.php
(Note that additional changes to Wysija Newletters are needed to get it to work with wp-db-driver)
The problem is due to last_result being used on line 300 of wp-db-drivers/db.php
before it gets set on line 303; the fix is straightforward.
Hi,
I was recently offered php 5.5 by my web host but presumably due to deprecation of MySql, your plugin has been the only way I have found to successfully run a wordpress site using it.
However, I am using W3 Total Cache plugin which creates its own db.php in wp-content and continually overwrites the file generated by WP DB Driver. Can you suggest a fix for this?
]]>Patch to fix this issue available at
https://github.com/markmont/wp-db-driver/commit/2ffcb1e7a18763dc51735e98da8cbfb05182f667
wb-db-driver plugin git revision 9febab3815 (head as of 2013-08-03), WordPress 3.6, PHP version 5.5.1, PDO driver, MariaDB version 5.5.31.
When a plugin calls dbDelta() to create a new database table (example code at the end of this post), the following errors get logged to PHP’s error_log, and the database table does not get created:
[03-Aug-2013 13:55:54 UTC] Error executing query: 42S02 - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'wp1.w19a_dbtest_table1' doesn't exist in query DESCRIBE w19a_dbtest_table1;
[03-Aug-2013 13:55:54 UTC] PHP Notice: Undefined property: stdClass::$Field in /www/w19a.catseye.org/wordpress/wp-admin/includes/upgrade.php on line 1561
[03-Aug-2013 13:55:54 UTC] Error executing query: 42S02 - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'wp1.w19a_dbtest_table1' doesn't exist in query SHOW INDEX FROM w19a_dbtest_table1;
[03-Aug-2013 13:55:54 UTC] WordPress database error Table 'wp1.w19a_dbtest_table1' doesn't exist for query SHOW INDEX FROM w19a_dbtest_table1; made by activate_plugin, do_action('activate_dbtest.php'), call_user_func_array, dbtest_activate, dbDelta, wpdb_drivers->query, wpdb_drivers->print_error
[03-Aug-2013 13:55:54 UTC] PHP Notice: Undefined property: stdClass::$Key_name in /www/w19a.catseye.org/wordpress/wp-admin/includes/upgrade.php on line 1609
[03-Aug-2013 13:55:54 UTC] PHP Notice: Undefined property: stdClass::$Column_name in /www/w19a.catseye.org/wordpress/wp-admin/includes/upgrade.php on line 1610
[03-Aug-2013 13:55:54 UTC] PHP Notice: Undefined property: stdClass::$Sub_part in /www/w19a.catseye.org/wordpress/wp-admin/includes/upgrade.php on line 1610
[03-Aug-2013 13:55:54 UTC] PHP Notice: Undefined property: stdClass::$Non_unique in /www/w19a.catseye.org/wordpress/wp-admin/includes/upgrade.php on line 1611
[03-Aug-2013 13:55:54 UTC] Error executing query: 42S02 - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'wp1.w19a_dbtest_table1' doesn't exist in query ALTER TABLE w19a_dbtest_table1 ADD COLUMN dbtest_key varchar(100) NOT NULL
[03-Aug-2013 13:55:54 UTC] WordPress database error Table 'wp1.w19a_dbtest_table1' doesn't exist for query ALTER TABLE w19a_dbtest_table1 ADD COLUMN dbtest_key varchar(100) NOT NULL made by activate_plugin, do_action('activate_dbtest.php'), call_user_func_array, dbtest_activate, dbDelta, wpdb_drivers->query, wpdb_drivers->print_error
[03-Aug-2013 13:55:54 UTC] Error executing query: 42S02 - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'wp1.w19a_dbtest_table1' doesn't exist in query ALTER TABLE w19a_dbtest_table1 ADD COLUMN dbtest_value varchar(100) NOT NULL
[03-Aug-2013 13:55:54 UTC] WordPress database error Table 'wp1.w19a_dbtest_table1' doesn't exist for query ALTER TABLE w19a_dbtest_table1 ADD COLUMN dbtest_value varchar(100) NOT NULL made by activate_plugin, do_action('activate_dbtest.php'), call_user_func_array, dbtest_activate, dbDelta, wpdb_drivers->query, wpdb_drivers->print_error
[03-Aug-2013 13:55:54 UTC] Error executing query: 42S02 - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'wp1.w19a_dbtest_table1' doesn't exist in query ALTER TABLE w19a_dbtest_table1 ADD PRIMARY KEY (dbtest_key)
[03-Aug-2013 13:55:54 UTC] WordPress database error Table 'wp1.w19a_dbtest_table1' doesn't exist for query ALTER TABLE w19a_dbtest_table1 ADD PRIMARY KEY (dbtest_key) made by activate_plugin, do_action('activate_dbtest.php'), call_user_func_array, dbtest_activate, dbDelta, wpdb_drivers->query, wpdb_drivers->print_error
The first error above is expected and correct; all of the other errors should not happen.
The problem occurs on line 1514 of wp-admin/includes/upgrade.php because the database driver should return false
when the table does not exist, but instead returns the last result object. This, in turn, is because line 1531 in wp-includes/wp-db.php (the get_results() method) always returns the instance’s last_result object, regardless of whether the query succeeded or failed. Finally, line 276 of wp-content/plugins/wp-db-driver/db.php (the query() method) returns on error without clearing the instance’s last_result object.
The db driver query() method always invokes the flush() method before executing the query. To fix the problem, I re-added the lines to flush() to clear last_result and other instance variables. This code was originaly in the flush() method, but this code was removed in the patch for Trac ticket #21663 for some reason.
Here is the example code for a plugin reproducing the problem (save this code as wp-content/plugins/dbtest.php). The problem occurs when the plugin is activated.
<?php
/*
Plugin Name: DB Test
Description: Demonstrates PDO DB driver problem
Version: 1.0
Author: Mark Montague
Author URI: https://mark.catseye.org/
License: GPL3
*/
function dbtest_activate() {
global $wpdb;
$table_name = $wpdb->prefix . "dbtest_table1";
$sql = "CREATE TABLE $table_name (
dbtest_key varchar(100) NOT NULL,
dbtest_value varchar(100) NOT NULL,
PRIMARY KEY (dbtest_key)
);";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );
]]>
I received these errors upon updating to 3.6-RC1-24757:
[22-Jul-2013 15:10:13 UTC] PHP Warning: Error while sending QUERY packet. PID=14707 in ...wp-content/plugins/wp-db-driver/drivers/pdo_mysql.php on line 109
[22-Jul-2013 15:10:13 UTC] Error executing query: HY000 - SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in query SELECT autoload FROM wptest209_options WHERE option_name = '_site_transient_update_core'
[22-Jul-2013 15:10:13 UTC] WordPress database error MySQL server has gone away for query SELECT autoload FROM wptest209_options WHERE option_name = '_site_transient_update_core' made by do_core_upgrade, wp_update_core, Core_Upgrader->upgrade, update_core, delete_site_transient, delete_site_option, delete_option, wpdb_drivers->query, wpdb_drivers->print_error
I have not tried to track it down and see why it was caused yet.
]]>Just installed this and I’m getting this repeatedly in the logs (I have WP_DEBUG
on):
PHP Notice: Undefined property: wpdb_drivers::$real_escape in ../wp-includes/wp-db.php on line 566
I haven’t been able to track down exactly what is causing it, other than that something is calling for $wpdb->real_escape
:
function __get( $name ) {
if ( 'col_info' == $name )
$this->load_col_info();
return $this->$name; /** 566 **/
}
I wasn’t getting this error before installing the plugin.
]]>WP 3.6-beta4-24523:
Any combination of extensions work, as long as at least one is installed.
Suggestion 1: Do not allow (the button) to remove the db.php
driver drop-in if mysql extension is not loaded, as this “suicide”. Not even on plugin deactivation. This suggestion is only relevant for the plugin as a tool.
Suggestion 2: For PHP 5.3 the mysql extension should have priority, then pdo, mysqli last. For PHP 5.2 the mysql extension should have priority, then mysql, pdo last.
Suggestion 3: Allow for a wp-config.php
constant to set driver (priority) as a string or serialized array: define ('WP_DB_DRIVER', serialize(array('mysqli', 'mysql', 'pdo')));
Will get back to these issues on trac.
]]>Hello, I installed the plugin on one of my blogs and I think works fine, or no show errors for now
But as owner of a blog in WordPress to me some doubts:
– how benefits me this plugin?
– Will my blog be faster?
– Will my blog be safer??
– Will my blog be more stable??
I’m no programmer so I do not understand the usefulness of this plugin, I would like to know more about it,
thanks for support, sorry for my english
]]>TEST 2:
Linux, Apache, PHP 5.4.16, PDO + mysgli + mysql, mysql 5.5.31:
Multisite, Domain mapping, Link Manager, Jetpack (most modules), custom post types, custom fields, custom taxonomies and custom archive queries.
No errors logged or visisble on any subsite.
TEST 3:
Same as above, without pdo_mysql extension, gave:
PHP Fatal error: Call to a member function fetch_object() on a non-object in []/public_html/wp-content/plugins/wp-db-driver/drivers/mysqli.php on line 117
This occurs regardless of mysqli and mysql extensions loaded instead.
TEST 4:
Same as above, with pdo_mysql, but without mysqli extension:
No errors logged or observed.
TEST 5:
Same as above with pdo_mysql, but without legacy mysql extension:
No errors logged or observed.
]]>