Basic Components - Record - Retrieving existing records.php 443 Bytes
Newer Older
doctrine's avatar
doctrine committed
1
<?php
2
$table = $conn->getTable("User");
doctrine's avatar
doctrine committed
3 4

// find by primary key
5 6 7 8

$user = $table->find(2);
if($user !== false)
    print $user->name;
doctrine's avatar
doctrine committed
9 10 11 12 13 14

// get all users
foreach($table->findAll() as $user) {
    print $user->name;
}

15 16
// finding by dql
foreach($table->findByDql("name LIKE '%John%'") as $user) {
doctrine's avatar
doctrine committed
17 18 19 20 21
    print $user->created;
}

// finding objects with DQL

22
$users = $conn->query("FROM User WHERE User.name LIKE '%John%'");
doctrine's avatar
doctrine committed
23
?>