cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

Db Schema missing when update using PHQL or SQL in Phalcon 3.0

Open leupom opened this issue 10 years ago • 2 comments

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.

leupom avatar Aug 09 '16 01:08 leupom

$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')

sergeyklay avatar Dec 24 '16 12:12 sergeyklay

http://stackoverflow.com/questions/22197678/how-to-connect-multiple-database-in-phalcon-framework

sergeyklay avatar Dec 24 '16 12:12 sergeyklay