cphalcon
cphalcon copied to clipboard
Db Schema missing when update using PHQL or SQL in Phalcon 3.0
Hi, I'm a developer from China ;-) English is a little bad.
Bug Sample: MySQL connection
'mysql' => [
'host' => '127.0.0.1',
'username' => 'root',
'password' => 'test',
'dbname' => 'db1',
'charset' => 'utf8',
],
There are two db, db1 and db2, when i use this code to update a row in db2:
Di::getDefault()->get('db')->updateAsDict('db2.table_1', ['column1' => '1'], 'id = 1')
Then occur an error:
SQLSTATE[42S02]: Base table or view not found: ...
This bug also encountered in PHQL when UPDATE model directly, not through findFirst way.
$di->set(
'db1',
function () {
return new Mysql(
[
'host' => '127.0.0.1',
'username' => 'root',
'password' => 'test',
'dbname' => 'db1',
'charset' => 'utf8',
]
);
}
);
$di->set(
'db2',
function () {
return new Mysql(
[
'host' => '127.0.0.1',
'username' => 'root',
'password' => 'test',
'dbname' => 'db2',
'charset' => 'utf8',
]
);
}
);
Di::getDefault()->get('db2')->updateAsDict('table_1', ['column1' => '1'], 'id = 1')
http://stackoverflow.com/questions/22197678/how-to-connect-multiple-database-in-phalcon-framework