Transactions: Table doesn't exist on database when dumping meta-data for model

Why does this Phalcon\Exception: Table "someDatabaseName" doesn't exist on database when dumping meta-data for MyModelName appear in such line: ```php $someMyModelInstance->setTransaction($transaction); ``` ?

I use exactly same way as in http://docs.phalconphp.com/en/latest/reference/models.html#isolated-transactions Also in other cases model works fine (database name and etc. are correct).



82.7k

An isolated transaction creates a new connection that must be shared by every model involved in the transaction. This means that a transaction cannot be performed over models in different databases servers.



20.7k

Both models in transaction use the same DB. But it has different name from 'db' in dependency injection container. Maybe this is the reason? Should I use $manager->setDbService() to sen connection name? If yes, why doesn't it get the name from the affected model?



82.7k

Yes, you need to set the database service the transaction must use:

$di['transactionManager'] = function(){
     $tx = new \Phalcon\Mvc\Model\Transaction\Manager();
     $tx->setDbService('x');
     return $tx;
};

Author's posts aren't counted because they could be 'hey I found out more info about this bug' or 'this also happens here when I...', and these aren't replies so other forum members could think the post doesn't need an answer

I got the same error when on multi modules system through following commands : phalcon create-all-models --get-set --mapcolumn --directory apps\frontend\models In controller file along with this I got the error: $ForexRates = ForexRates::find(); print_r($ForexRates);

Got the error: Notice: Array to string conversion in C:\xampp\htdocs\testingtoday\apps\frontend\Module.php on line 78 Notice: Array to string conversion in C:\xampp\htdocs\testingtoday\apps\frontend\Module.php on line 78 Table 'forex_rates' doesn't exist in database when dumping meta-data for testingtoday\frontend\Models\ForexRates

And on following line changed the code : in testingtoday\apps\frontend Module.php

$di['db'] = function () use ($config) { // return new DbAdapter($config->toArray()); //}; To Replaces with : $di['db'] = function() use ($config) { // return new DbAdapter(array( "host" =>$config->database->host, "username" => $config->database->username, "password" => $config->database->password, "dbname" => $config->database->dbname )); };