1
0
mirror of synced 2024-12-15 15:46:02 +03:00
doctrine2/manual/docs/Working with objects - Component overview - Collection - Adding new elements.php

20 lines
437 B
PHP
Raw Normal View History

2007-04-14 01:49:11 +04:00
When accessing single elements of the collection and those elements (records) don't exist Doctrine auto-adds them.
In the following example
we fetch all users from database (there are 5) and then add couple of users in the collection.
As with PHP arrays the indexes start from zero.
<code type="php">
$users = $table->findAll();
print count($users); // 5
$users[5]->name = "new user 1";
$users[6]->name = "new user 2";
</code>