/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $data = (object) array(); $this->gacela = \Gacela\Gacela::instance(); $m = $this->gacela->loadMapper('Test'); $this->object = new Test\Model\Test(get_class($m), $data); }
public function remove($student, $course) { $this->student = Gacela::instance()->loadMapper('student')->find($student); $course = Gacela::instance()->loadMapper('course')->find($course); $this->student->remove($course); $this->_redirect('/associations/student/' . $student); }
public function index() { $this->template = 'debug'; $this->title = 'Debugging Mappers'; $this->house = \Gacela::instance()->loadMapper('house'); $houses = $this->house->findAll(); $this->student = \Gacela::instance()->loadMapper('student'); }
public function form($id = null) { $this->model = \Gacela::instance()->loadMapper('wizard')->find($id); $this->template = 'dependents_form'; $this->title = 'Dependent Mapping - Set Wizard Location'; $this->message = ''; if (count($_POST)) { $this->model->locationName = $_POST['locationName']; if (!$this->model->save()) { $this->message = debug($this->model->errors); } else { $this->message = 'Location Saved'; } } }
protected function _load($data) { if (!empty($data->role) && $data->role == 'student' && get_class($this) != 'App\\Mapper\\Student') { // Because students load from their mapper that allows them to inherit // from the wizards resource return \Gacela::instance()->loadMapper('student')->load($data); } if (!empty($data->role)) { $model = ucfirst($data->role); } else { $model = 'Wizard'; } $model = '\\App\\Model\\' . $model; return new $model(get_class($this), $data); }
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); }
public function delete($id) { $course = Gacela::instance()->loadMapper('course')->find($id); $course->delete(); $this->_redirect('/belongsto'); }
public function delete($id) { $model = Gacela::instance()->loadMapper('house')->find($id); $model->delete(); $this->_redirect('/crud'); }
public function teacher($id = null) { $this->teacher = Gacela::instance()->loadMapper('teacher')->find($id); $this->template = 'hasmany_teacher'; $this->title = 'Has Many Relationships - Teacher Courses'; }
<?php /** * @author noah * @date 4/20/11 * @brief * */ require_once '../library/Gacela.php'; $gacela = Gacela::instance(); $gacela->registerNamespace('App', __DIR__); set_exception_handler(array('Gacela\\Exception', 'handler')); $db = $gacela::createDataSource(array('name' => 'db', 'type' => 'mysql', 'schema' => 'gacela', 'host' => 'localhost', 'password' => 'gacela', 'user' => 'gacela')); $wiki = $gacela::createDataSource(array('name' => 'wiki', 'type' => 'mysql', 'schema' => 'wiki', 'host' => 'localhost', 'user' => 'gacela', 'passwword' => 'gacela')); $employees = $gacela::createDataSource(array('name' => 'employees', 'type' => 'mysql', 'schema' => 'employees', 'host' => 'localhost', 'user' => 'gacela', 'passwword' => 'gacela')); $gacela->registerDataSource($db)->registerDataSource($wiki)->registerDataSource($employees); $memcache = new Memcache(); $memcache->addServer('127.0.0.1', 11211); //$gacela->enableCache($memcache); // Comment out to avoid using the config files and use the dynamic version instead //$gacela->configPath(__DIR__.'/config'); function debug($value) { return '<pre>' . print_r($value, true) . '</pre>'; }
public function slice($offset, $length = null) { $data = array_slice($this->_data, $offset, $length); return \Gacela::instance()->makeCollection($this->_mapper, $data); }
public function delete($id) { $model = Gacela::instance()->loadMapper('teacher')->find($id); $model->delete(); $this->_redirect('/singleInheritance'); }
/** * @covers Gacela::makeCollection * @expectedException Gacela\Exception */ public function testMakeCollectionThrowsException() { $mapper = new Test\Mapper\Peep(); $this->object->makeCollection($mapper, new \ArrayObject()); }
public function delete($id) { $student = Gacela::instance()->loadMapper('student')->find($id); $student->delete(); $this->_redirect('/concreteInheritance'); }