1
0
mirror of synced 2024-12-15 07:36:03 +03:00
doctrine2/manual/codes/Working with objects - Component overview - Collection - Key mapping.php
2007-02-23 20:57:38 +00:00

32 lines
613 B
PHP

<?php
// mapping id column
$user = new User();
$user->setAttribute(Doctrine::ATTR_COLL_KEY, 'id');
// now user collections will use the values of
// id column as element indexes
$users = $user->getTable()->findAll();
foreach($users as $id => $user) {
print $id . $user->name;
}
// mapping name column
$user = new User();
$user->setAttribute(Doctrine::ATTR_COLL_KEY, 'name');
// now user collections will use the values of
// name column as element indexes
$users = $user->getTable()->findAll();
foreach($users as $name => $user) {
print $name . $user->type;
}
?>