Answer the question
In order to leave comments, you need to log in
How to add one record in two tables (different databases)?
There is a task when adding one record to the table {table} in the database {bd1} add to {bd2} in the same table
Copied model Item and named ItemExport and inherited from Item since the tables are the same (deleted all methods and added getDbConnection() )
then when saving in afterSave, Item will save in ItemExport
Also, ItemExport has this to connect to {bd2}
public function getDbConnection()
{
return Yii::app()->dbexport;
}
$item = ItemExport::model()->findByAttributes(array('id_table_bd1' => $this->id));
gives an error that there is no such field, Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question