开发者

Doctrine - Set One Object Equal to Another

开发者 https://www.devze.com 2023-02-28 11:19 出处:网络
In Doctrine / Php / MySQL, im trying to pull one record fr开发者_C百科om the DB that is in Table A.I then want to take that row, and insert it into Table B (which has the exact same structure as Table

In Doctrine / Php / MySQL, im trying to pull one record fr开发者_C百科om the DB that is in Table A. I then want to take that row, and insert it into Table B (which has the exact same structure as Table A).

Whats the best way to do this?


If the two tables have identical structures I think you can do something like:

$B = new TableB();
$B->fromArray($A->toArray());
$B->save();

this is ok only for few records. If you need to copy a lot of records and need performances use PDO with insert into B/select from A type queries!

0

精彩评论

暂无评论...
验证码 换一张
取 消