? ? Failure

User tests: Successful: Unsuccessful:

avatar mbabker
mbabker
20 Aug 2016

Pull Request porting joomla-framework/database#38.

Summary of Changes

This implements prepared statement support for the MySQLi driver.

Note this API was originally created for PDO based drivers so it has a "funny" API for our non-PDO code. None the less it's still usable.

Also consistently uses the OOP style mysqli API versus procedural since we're storing an object anyway. Only in methods where a cursor can be injected does the procedural style remain.

Testing Instructions

The prepared statement API really isn't documented because none of the drivers that the CMS application supports use this feature, until now. With that said, the best demonstration of how to use it for MySQLi can be found in the added unit test case for the driver itself. Testing existing code on a MySQLi environment by replacing values with bound parameters as demonstrated in the test case should suffice for this. As an example, you could update JComponentHelper::load() to use this code snippet:

// The bind method uses references for the second argument, so we need to make this a variable
$type = 'component';

$db = JFactory::getDbo();
$query = $db->getQuery(true)
    ->select('extension_id AS id, element AS "option", params, enabled')
    ->from('#__extensions')
    ->where($db->quoteName('type') . ' = ?')
    ->bind(1, $type);
$db->setQuery($query);

Documentation Changes Required

N/A; the prepared statement API is only documented via the automatically generated API documentation

avatar joomla-cms-bot joomla-cms-bot - change - 20 Aug 2016
Category Libraries Unit Tests
avatar mbabker mbabker - open - 20 Aug 2016
avatar mbabker mbabker - change - 20 Aug 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 20 Aug 2016
Labels Added: ? ?
avatar mbabker
mbabker - comment - 20 Aug 2016

If someone wants to take a guess on the unit test failures, it'd help me out some because I'm at a loss here. The iterator tests are failing because one of the records inserted in the driver's transaction tests seems to not be coming out of the database and I've got no logical reason for this.

avatar photodude
photodude - comment - 5 Sep 2016

What's going on with the PHP Fatal error on travis?

PHP Fatal error:  Uncaught Error while sending STATISTICS packet. PID=3347
/tests/unit/core/helper/helper.php:52
/libraries/joomla/database/driver/mysqli.php:239
/libraries/joomla/database/driver/mysqli.php:115
  thrown in /libraries/joomla/database/driver/mysqli.php on line 239
PHP Stack trace:
PHP   1. {main}() /libraries/vendor/phpunit/phpunit/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /libraries/vendor/phpunit/phpunit/phpunit:47
PHP   3. PHPUnit_TextUI_Command->run() /libraries/vendor/phpunit/phpunit/src/TextUI/Command.php:100
avatar mbabker
mbabker - comment - 5 Sep 2016

If you figure it out let me know ?

On Monday, September 5, 2016, Walt Sorensen notifications@github.com
wrote:

What's going on with the PHP Fatal error?

PHP Fatal error: Uncaught Error while sending STATISTICS packet. PID=3347/tests/unit/core/helper/helper.php:52/libraries/joomla/database/driver/mysqli.php:239/libraries/joomla/database/driver/mysqli.php:115 thrown in /libraries/joomla/database/driver/mysqli.php on line 239PHP Stack trace:PHP 1. {main}() /libraries/vendor/phpunit/phpunit/phpunit:0PHP 2. PHPUnit_TextUI_Command::main() /libraries/vendor/phpunit/phpunit/phpunit:47PHP 3. PHPUnit_TextUI_Command->run() /libraries/vendor/phpunit/phpunit/src/TextUI/Command.php:100


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#11696 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAWfoanMFovEK9capkkDeAUDQIzHwCF4ks5qnJ-6gaJpZM4JpH3Y
.

avatar photodude
photodude - comment - 6 Sep 2016

Best guess, some issue with the mysql connect() method.

considering that one of the only parts which doesn't have a condition check is Set sql_mode to non_strict mode that would be my first guess. That or mysql is timing out during the tests, or max_allowed_packet setting for MySQL is too low

avatar mbabker
mbabker - comment - 12 Sep 2016

Closing due to lack of interest, an inability to use prepared statements on all supported databases (the legacy MySQL driver does not support prepared statements in any way), and my being unable to address the unit test issues.

avatar mbabker mbabker - change - 12 Sep 2016
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2016-09-12 20:54:14
Closed_By mbabker
avatar photodude
photodude - comment - 13 Sep 2016

I hope this can be addressed at some point in the future...

avatar photodude
photodude - comment - 29 Jan 2017

@mbabker I hope you will revisit these Prepared statement support PR's now that we have the testing issues sorted out in the Framework.

avatar mbabker
mbabker - comment - 29 Jan 2017

I will in due time.

Add a Comment

Login with GitHub to post a comment