User tests: Successful: Unsuccessful:
Pull Request porting joomla-framework/database#38.
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.
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);
N/A; the prepared statement API is only documented via the automatically generated API documentation
Category | ⇒ | Libraries Unit Tests |
Status | New | ⇒ | Pending |
Labels |
Added:
?
?
|
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
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
.
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
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.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-09-12 20:54:14 |
Closed_By | ⇒ | mbabker |
I hope this can be addressed at some point in the future...
I will in due time.
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.