Doctrine - 只用一个save()插入多行

Alm*_*bek 19 php database doctrine insert save

如何save()Doctrine中将多行插入表调用方法?

xzy*_*fer 31

将每条记录添加到集合对象上的Doctrine_Collection调用save().

$collection = new Doctrine_Collection('tablename');
$collection->add($record1);
$collection->add($record2);
$collection->add($record3);
$collection->add($record4);
$collection->save();
Run Code Online (Sandbox Code Playgroud)

仅当所有记录都针对同一个表时才有效.否则你运气不好.

  • 太棒了!插入1000行只需3.8s而不是76s! (11认同)