$hook=newDoctrine_Hook('SELECT u.name FROM User u LEFT JOIN u.Phonenumber p');
$a['orderby']=array('u.name ASC');
$hook->hookOrderBy($a['orderby']);
$this->assertEqual($hook->getQuery()->getQuery(),'SELECT e.id AS e__id, e.name AS e__name FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0) ORDER BY e.name ASC');
$hook=newDoctrine_Hook('SELECT u.name FROM User u LEFT JOIN u.Phonenumber p');
$a['orderby']=array('u.name DESC');
$hook->hookOrderBy($a['orderby']);
$this->assertEqual($hook->getQuery()->getQuery(),'SELECT e.id AS e__id, e.name AS e__name FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0) ORDER BY e.name DESC');
$hook=newDoctrine_Hook('SELECT u.name FROM User u LEFT JOIN u.Phonenumber p');
$a['orderby']=array('u.unknown DESC');
$hook->hookOrderBy($a['orderby']);
$this->assertEqual($hook->getQuery()->getQuery(),'SELECT e.id AS e__id, e.name AS e__name FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)');
$this->assertEqual($hook->getQuery()->getQuery(),'SELECT e.id AS e__id, e.name AS e__name FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0) ORDER BY e.name ASC, e.id DESC');
$hook=newDoctrine_Hook('SELECT u.name FROM User u LEFT JOIN u.Phonenumber p');
$a['where']=array('u.name'=>'Jack Daniels',
'u.loginname'=>'TheMan');
$hook->hookWhere($a['where']);
$this->assertEqual($hook->getQuery()->getQuery(),'SELECT e.id AS e__id, e.name AS e__name FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.name LIKE ? OR e.name LIKE ?) AND e.loginname LIKE ? AND (e.type = 0)');
$this->assertEqual($hook->getQuery()->getQuery(),'SELECT e.id AS e__id, e.name AS e__name FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE e.id = ? AND (e.type = 0)');
$hook=newDoctrine_Hook('SELECT u.name FROM User u LEFT JOIN u.Phonenumber p');
$a['where']=array('u.unknown'=>'Jack Daniels');
$hook->hookWhere($a['where']);
2007-07-06 03:47:48 +04:00
$this->assertEqual($hook->getQuery()->getSql(),'SELECT e.id AS e__id, e.name AS e__name FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)');