Reputation: 59
I need to copy a table in a database to another database both in same server in Yii. So for that i can use a single query to get all values but the query need to execute two databases. In Yii. I have db and db2 in my config file
so,
$connection1 = Yii::app()->db1;
$connection2 = Yii::app()->db2;
$sql = "insert into test ()values()"; // Need two database table access ??
$command = $connection->createCommand($sql); //How can i execute using both connections??
$row = $command->execute();
Please help..
Thanks!
Upvotes: 0
Views: 551
Reputation: 46
If user in any DB connection have access to both tables you can transfer data just in one query. You need no second connection or query. You need just to use name of second database and use database.table names.
Upvotes: 2