Working with objects - Component overview - Table - Finder methods.php 601 Bytes
Newer Older
hansbrix's avatar
hansbrix committed
1 2
Doctrine_Table provides basic finder methods. These finder methods are very fast and should be used if you only need to fetch 
data from one database table. If you need queries that use several components (database tables) use Doctrine_Connection::query().
3

hansbrix's avatar
hansbrix committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<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;
}
</code>