Arvind Kapse Arvind Kapse - 7 months ago 209
PHP Question

Copy one table to another in laravel 5

How do i use the following insert into query in laravel 5?

INSERT INTO connection2.table (SELECT * from connection1.table);


I am looking for two different connections, Connection1.table record should goes to Connection2.table.

Answer

try

$c1 = DB("Connection1")->select("SELECT * from table")

foreach($c1 as $record){

    DB("Connection2")->table("table")->insert($record)

}
Comments