core
core copied to clipboard
Handle PDO drivers (notably ODBC) which do not implement PDO::quote()
Issue
When using the PDO ODBC driver, which does not implement PDO::quote, SQL syntax errors occur.
Reproduce
Connect to MySQL using the PDO ODBC driver:
'default' => array(
'type' => 'pdo',
'connection' => array(
'dsn' => 'odbc:Driver={MySQL ODBC 5.1 Driver};Server={localhost};Database={fuel_test};Uid={fuel};Pwd={****}',
'username' => 'fuel',
'password' => '****',
),
'identifier' => '`',
)
Create an ORM model. Try an update:
$entry = Model_User::find('first');
$entry->name = "Testing";
$entry->save();
Observe the invalid SQL query produced:
UPDATE `users` SET `name` = WHERE `id` =
Cause
In core/classes/database/pdo/connection.php, the 'escape' method looks like this:
public function escape($value)
{
// Make sure the database is connected
$this->_connection or $this->connect();
return $this->_connection->quote($value);
}
The PDO ODBC driver doesn't implement the 'quote' method.
Solution
Update the PDO driver to deal with any drivers which do not implement PDO::quote.
More info
@FrenkyNet any idea how to do this? How did you deal with this in Cabinet (if you did, and if not, it's an issue there too ;-))
@mtmacdonald, can you check if this workaround helps?
@WanWizard - thanks. I've tested this against MySQL connected through ODBC. This appears to solve the issue.
@WanWizard. There were two unrelated database issues: dbs which do not support the LIMIT clause (impacts ORM) and dbs which do not support lastInsertId() (impacts sessions). Should these be registered as tickets as too?