? ? Pending

User tests: Successful: Unsuccessful:

avatar mbabker
mbabker
20 Aug 2016

Pull Request porting joomla-framework/database@66035e4.

Summary of Changes

This implements prepared statement support for the PDO MySQL driver. The base PDO driver class inherently supports prepared statements for all PDO based objects but the query builder class must implement the required interface for this to work.

Additionally, the unit test class for the query object is backported from the Framework.

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 PDO can be found in the added unit test case for the driver itself. Testing existing code on a PDO MySQL 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') . ' = :component')
    ->bind('component', $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 - 12 Sep 2016

Closing due to lack of interest and an inability to use prepared statements on all supported databases (the legacy MySQL driver does not support prepared statements in any way).

avatar mbabker mbabker - change - 12 Sep 2016
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2016-09-12 20:53:54
Closed_By mbabker

Add a Comment

Login with GitHub to post a comment