[wp-trac] [WordPress Trac] #21663: Use PDO for MySQL queries when PDO is available

WordPress Trac wp-trac at lists.automattic.com
Wed Aug 22 21:45:14 UTC 2012


#21663: Use PDO for MySQL queries when PDO is available
---------------------------+------------------------------
 Reporter:  scottconnerly  |       Owner:
     Type:  enhancement    |      Status:  new
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Database       |     Version:
 Severity:  normal         |  Resolution:
 Keywords:  needs-patch    |
---------------------------+------------------------------
Changes (by kurtpayne):

 * cc: kpayne@… (added)


Comment:

 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.
         }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21663#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list