tags:

views:

121

answers:

2

i save a user like this in doctrine:

$user = User();
$user->name = 'peter';
$user->save();

is there a way to save 20 users in one sql query?

or do i have to loop the above code 20 times hence creating 20 sql queries?

thanks

+2  A: 

From your point of view as a Doctrine user, you are working with objects, and should not be concerned by SQL queries.

If you have 20 different users, then, you should have 20 different objects -- which means, yes, 20 queries (or more, depending on what your objects are doing) to save them.

Pascal MARTIN
+5  A: 

You may add your $user objects to Doctrine_Collection and then call $collection->save(), which basically does the loop for you.

takeshin