/** * @covers Gacela\Mapper\Mapper::findAll */ public function testFindAllWithCriteria() { $criteria = new Gacela\Criteria(); $criteria->isNotNull('completed'); $col = $this->object->findAll($criteria); $this->assertSame(1, $col->count()); }
public function findAll(\Gacela\Criteria $criteria = null) { if (is_null($criteria)) { $criteria = new \Gacela\Criteria(); } $criteria->equals('role', 'teacher'); return parent::findAll($criteria); }
public function index() { $criteria = new \Gacela\Criteria(); $criteria->sort('fname')->sort('lname', 'desc'); $this->students = Gacela::instance()->loadMapper('student')->findAll($criteria); $this->template = 'concrete-inheritance_index'; $this->title = 'Concrete Inheritance'; }
public function index() { $criteria = new \Gacela\Criteria(); // For this list we only want to see teachers $criteria->notEquals('role', 'student'); $this->wizards = Gacela::instance()->loadMapper('wizard')->findAll($criteria); $this->template = 'single-inheritance_index'; $this->title = 'Single Table Inheritance - List of Students'; }
public function student($id) { $this->student = Gacela::instance()->loadMapper('student')->find($id); $this->template = 'student_associations'; $this->title = 'Classes: ' . $this->student->fullName; if (count($_POST)) { $course = Gacela::instance()->loadMapper('course')->find($_POST['courseId']); $this->student->add($course); } $criteria = new Gacela\Criteria(); $courses = $this->student->courses->asArray('courseId'); $criteria->notIn('courseId', $courses); $this->courses = Gacela::instance()->loadMapper('course')->findAll($criteria); }
public function index() { $this->template = 'criteria'; $this->title = 'Criteria vs. Query in Gacela'; $criteria1 = new \Gacela\Criteria(); // Limit to only students who have no address specified $criteria1->equals('role', 'student')->isNull('locationName'); $criteria2 = new \Gacela\Criteria(); // Pull back all wizards who are students $criteria2->equals('role', 'student'); $this->noAddresses = \Gacela::instance()->loadMapper('wizard')->findAll($criteria1); $this->totalStudents = \Gacela::instance()->loadMapper('wizard')->findAll($criteria2); $this->withCourse = \Gacela::instance()->loadMapper('teacher')->findAllWithCourse(); $this->withoutCourse = \Gacela::instance()->loadMapper('teacher')->findAllWithoutCourse(); $criteria = new \Gacela\Criteria(); $criteria->notLike('lName', 'e'); $this->noE = \Gacela::instance()->loadMapper('teacher')->findAllWithCourse($criteria); }
/** * @param array $primary * @param Resource $resource * @param array $inherits * @param array $dependents * @return */ public function find(array $primary, \Gacela\DataSource\Resource $resource, array $inherits = array(), array $dependents = array()) { $crit = new \Gacela\Criteria(); foreach ($primary as $key => $val) { $crit->equals($resource->getName() . '.' . $key, $val); } return $this->query($resource, $this->_buildFinder($this->getQuery($crit), $resource, $inherits, $dependents))->fetchObject(); }