1
0
mirror of synced 2025-01-18 22:41:43 +03:00
doctrine2/manual/codes/Basic Components - Record - Retrieving existing records.php
2006-07-23 21:08:06 +00:00

25 lines
488 B
PHP

<?php
$table = $session->getTable("User");
// find by primary key
try {
$user = $table->find(2);
} catch(Doctrine_Find_Exception $e) {
print "Couldn't find user";
}
// get all users
foreach($table->findAll() as $user) {
print $user->name;
}
// finding by sql
foreach($table->findBySql("name LIKE '%John%'") as $user) {
print $user->created;
}
// finding objects with DQL
$users = $session->query("FROM User WHERE User.name LIKE '%John%'");
?>