Working with objects - Component overview - Query - Method overloading.php 569 Bytes
Newer Older
hansbrix's avatar
hansbrix committed
1
You can overload the query object by calling the dql query parts as methods. 
2

hansbrix's avatar
hansbrix committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
<code type="php">
$conn = Doctrine_Manager::getInstance()->openConnection(new PDO("dsn","username","password"));

$query = new Doctrine_Query($conn);

$query->from("User-b")
      ->where("User.name LIKE 'Jack%'")
      ->orderby("User.created")
      ->limit(5);

$users = $query->execute();

$query->from("User.Group.Phonenumber")
      ->where("User.Group.name LIKE 'Actors%'")
      ->orderby("User.name")
      ->limit(10)
      ->offset(5);
      
$users = $query->execute();
</code>