Open waqasajaz opened 10 years ago
line 73 of php-activerecord/lib/adapters/MysqlAdapter.php
contains offending code. It is directly executing query instead of preparing it.
public function set_encoding($charset)
{
$params = array($charset);
$this->query('SET NAMES ?',$params);
}
changing above function to below one resolves the issue.
public function set_encoding($charset)
{
$this->query('SET NAMES ' . $charset));
}
For more details see http://stackoverflow.com/a/19291558/649388
Above fix breaks the build though.
%php -v
PHP 5.3.26 (cli) (built: Jul 7 2013 19:05:08)
Copyright (c) 1997-2013 The PHP Group
...
1) MysqlAdapterTest::test_set_charset
PDOStatement::execute() expects parameter 1 to be array, string given
/Users/tuupola/Code/php/php-activerecord/lib/Connection.php:320
/Users/tuupola/Code/php/php-activerecord/lib/adapters/MysqlAdapter.php:76
/Users/tuupola/Code/php/php-activerecord/lib/Connection.php:117
/Users/tuupola/Code/php/php-activerecord/test/MysqlAdapterTest.php:24
@tuupola thanks for the test. Can you suggest a fix for this issue please. Let me admit that I have no idea what this issue is all about. It 'll be great if you can guide me how to run its test cases.
I am adding
PDO::ATTR_EMULATE_PREPARES => false
to$PDO_OPTIONS
array in file../lib/Connection.php
at line54. It is causing uncaught exception at:../lib/adapters/MysqlAdapter.php(76): ActiveRecord\Connection->query('SET NAMES ?', Array)
exception:
Stack Trace:
any idea?