[drupal-devel] [feature] MySQLi support
m3avrck
drupal-devel at drupal.org
Mon Aug 29 17:02:06 UTC 2005
Issue status update for
http://drupal.org/node/29910
Post a follow up:
http://drupal.org/project/comments/add/29910
Project: Drupal
Version: cvs
Component: database system
Category: feature requests
-Priority: critical
+Priority: normal
Assigned to: Anonymous
Reported by: nsk
Updated by: m3avrck
-Status: patch (ready to be committed)
+Status: patch (code needs review)
Updated status of feature request.
m3avrck
Previous comments:
------------------------------------------------------------------------
Mon, 29 Aug 2005 06:59:53 +0000 : nsk
Attachment: http://drupal.org/files/issues/nskpatch.tar.bz2 (4.14 KB)
I added MySQLi support to Drupal by adding a database.mysqli.inc file.
After chx's suggestion I also removed $row from db_result from both
mysqli and mysql files.
Users are supposed to connect to Drupal with a mysqli "URL" in their
settings.php. Just adding an "i" in the mysql entry in settings.php
would work.
MySQLi is the new MySQL client in PHP which connects to MySQL 4.1, 5.0
and beyond. MySQLi replaces the older MySQL library which was popular
with MySQL 3.23 and 4.0.
http://gr.php.net/manual/en/ref.mysqli.php
The older MySQL client does not support full functionality with MySQL
4.1, that's why MySQLi is important.
MySQLi works in PHP 4.1.3 or above, and is more popular in PHP 5.
MySQLi means MySQL Improved.
This patch should be included in core.
------------------------------------------------------------------------
Mon, 29 Aug 2005 07:08:07 +0000 : nsk
Attachment: http://drupal.org/files/issues/nskpatch1.diff (7.1 KB)
Here is the diff for mysqli against Drupal CVS HEAD.
------------------------------------------------------------------------
Mon, 29 Aug 2005 07:08:56 +0000 : nsk
Attachment: http://drupal.org/files/issues/nskpatch2.diff (645 bytes)
Here is the diff for mysql against DRUPAL CVS HEAD. The change was
proposed by chx on IRC.
------------------------------------------------------------------------
Mon, 29 Aug 2005 07:13:28 +0000 : nsk
With this message hereby I release all my changes to the files in this
patch (database.mysqli.inc and database.mysql.inc) in GPL 2 (and later
versions), as well as releasing them into the public domain. The
changes I made are show in the diffs. An external URL where users can
find some documentation is:
http://jnanabase.org/index.php/User:NSK/Software/drupal_and_mysqli
------------------------------------------------------------------------
Mon, 29 Aug 2005 13:22:42 +0000 : Thomas Ilsche
big +1, however not tested yet (will do later today)
------------------------------------------------------------------------
Mon, 29 Aug 2005 16:03:33 +0000 : Thox
See duplicate issue: #24264 [1].
[1] http://drupal.org/node/24264
------------------------------------------------------------------------
Mon, 29 Aug 2005 16:16:17 +0000 : m3avrck
Using that file, I get this error right away:
Parse error: syntax error, unexpected ',' in C:\Documents and
Settings\tserbinski\My
Documents\websites\drupal_cvs\drupal\includes\database.mysqli.inc on
line 34
Doing some digging through the documentation, it looks like the
mysqli_real_connect() [2] is being used *improplerly*.
This function call works with no problems:
@mysqli_real_connect($connection, $url['host'], $url['user'],
$url['pass'], (substr($url['path'], 1)), $url['port'], null,
MYSQLI_CLIENT_FOUND_ROWS);
If this is indeed the correct call (it appears to be but can't really
test whether the ports, sockets part is working), then the code circa
line 27 that checks for the port can be deleted since the function call
handles this.
Additionally, the database check on line 51 needs to be moved up since
the database is selected during the mysqli_real_connect() now.
Overall, code needs some work and cleanup.
Peformance wise, noticed a 10ms decrease in page generation times for a
few pages (not thorougly tested performance wise however, just a quick
and dirty observation).
[2] http://us2.php.net/manual/en/function.mysqli-real-connect.php
------------------------------------------------------------------------
Mon, 29 Aug 2005 16:17:34 +0000 : m3avrck
Forgot to mention tested this with PHP5.0.3 and MySQL 4.1.11 on Windows
2003 SP1.
------------------------------------------------------------------------
Mon, 29 Aug 2005 16:20:36 +0000 : m3avrck
Thox, the reported duplicate issue is using an out of date
database.mysql.inc file. I believe Drumm added quite a bit of code for
friendlier errors. Seems those two files need to be merged for proper
MySQLi support. I'll see what I can do later today if I have some time.
------------------------------------------------------------------------
Mon, 29 Aug 2005 16:56:24 +0000 : m3avrck
Attachment: http://drupal.org/files/issues/database.mysqli_2.inc (8.51 KB)
Ok I've taken the latest HEAD version of database.mysql.inc, merged this
with NSK's recommendations, and then merged that with Thox's
database.mysqli.inc (see link a few comments up) whose database code
was based on out of an out of date version of the include file.
Also went through and tweaked and it looks like this patch is ready to
go. Just tested it here and it is running *now* on average, 40ms
*faster* than the regular mysql library.
Patch needs some more testing but I believe it is ready to go.
Optionally, lines 27 can be removed and the mysqli_real_connect() can
be updated with the $url['port']. No way to confirm if this will work
100% but we can get rid of some extraneous code if someone can confirm.
See attached file.
More information about the drupal-devel
mailing list