Working with objects - Component overview - Record - Accessing properties.php 600 Bytes
Newer Older
hansbrix's avatar
hansbrix committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
You can retrieve existing objects (database rows) with Doctrine_Table or Doctrine_Connection. 
Doctrine_Table provides simple methods like findBySql, findAll and find for finding objects whereas 
Doctrine_Connection provides complete OQL API for retrieving objects (see chapter 9). 

<code type="php">
$user = $table->find(3);

// access property through overloading

$name = $user->name;

// access property with get()

$name = $user->get("name");

// access property with ArrayAccess interface

$name = $user['name'];

// iterating through properties

foreach($user as $key => $value) {

}
</code>