1
0
mirror of synced 2024-12-15 07:36:03 +03:00
doctrine2/manual/docs/Working with objects - Component overview - Record - Retrieving existing records.php

28 lines
690 B
PHP
Raw Normal View History

2007-04-14 01:49:11 +04:00
Doctrine provides many ways for record retrieval. The fastest ways for retrieving existing records
are the finder methods provided by Doctrine_Table. If you need to use more complex queries take a look at
DQL API and Doctrine_Connection::query method.
2007-04-14 01:49:11 +04:00
<code type="php">
$table = $conn->getTable("User");
// find by primary key
$user = $table->find(2);
if($user !== false)
print $user->name;
// get all users
foreach($table->findAll() as $user) {
print $user->name;
}
// finding by dql
foreach($table->findByDql("name LIKE '%John%'") as $user) {
print $user->created;
}
// finding objects with DQL
$users = $conn->query("FROM User WHERE User.name LIKE '%John%'");
</code>