[wp-trac] [WordPress Trac] #21663: Use PDO or mysqli for MySQL queries when available
WordPress Trac
noreply at wordpress.org
Wed Feb 26 14:13:23 UTC 2014
#21663: Use PDO or mysqli for MySQL queries when available
------------------------------+------------------
Reporter: scottconnerly | Owner:
Type: task (blessed) | Status: new
Priority: normal | Milestone: 3.9
Component: Database | Version: 3.5
Severity: normal | Resolution:
Keywords: has-patch commit | Focuses:
------------------------------+------------------
Comment (by AzizSaleh):
Replying to [comment:1 kurtpayne]:
> Would it make sense to create translation functions for mysql_* if
they're not available?
>
> I can see this being a saving grace for plugins / themes that do not use
`$wpdb`. [http://plugins.svn.wordpress.org/activehelper-
livehelp/trunk/server/import/class.mysql.php Example plugin]
>
> Incomplete non-functioning concept code:
>
> {{{
> #!php
> <?php
>
> if (!function_exists('mysql_query')) {
> $pdo_conn = null;
> function mysql_connect($host = 'localhost', $user = '', $pass = ''
) {
> global $pdo_conn = new PDO('mysql:;host=' . $host, $user,
$pass);
> }
> function mysql_query($sql) {
> global $pdo_conn;
> return $pdo_conn->query($sql);
> }
> function mysql_fetch_assoc($rs) {
> return $rs->fetch(PDO::FETCH_ASSOC);
> }
> // ... etc.
> }
> }}}
That is exactly what I did for my library to enable sites to work without
mysql_* functions using PDO as a backend:
https://github.com/AzizSaleh/mysql
Copy those files to a folder and then in your wordpress wp-
includes/load.php file replace the following two lines:
`wp_load_translations_early();
die( __( 'Your PHP installation appears to be missing the MySQL extension
which is required by WordPress.' ) );`
With the following:
`$pathToMySQL = 'C:\\xampp\\htdocs\\mysql\\';
require_once($pathToMySQL . 'MySQL_Definitions.php');
require_once($pathToMySQL . 'MySQL.php');
require_once($pathToMySQL . 'MySQL_Functions.php');`
--
Ticket URL: <https://core.trac.wordpress.org/ticket/21663#comment:208>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list