Ejemplo n.º 1
0
 /**
  * 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);
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 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');
 }
Ejemplo n.º 4
0
 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';
         }
     }
 }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 7
0
 public function delete($id)
 {
     $course = Gacela::instance()->loadMapper('course')->find($id);
     $course->delete();
     $this->_redirect('/belongsto');
 }
Ejemplo n.º 8
0
 public function delete($id)
 {
     $model = Gacela::instance()->loadMapper('house')->find($id);
     $model->delete();
     $this->_redirect('/crud');
 }
Ejemplo n.º 9
0
 public function teacher($id = null)
 {
     $this->teacher = Gacela::instance()->loadMapper('teacher')->find($id);
     $this->template = 'hasmany_teacher';
     $this->title = 'Has Many Relationships - Teacher Courses';
 }
Ejemplo n.º 10
0
<?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>';
}
Ejemplo n.º 11
0
 public function slice($offset, $length = null)
 {
     $data = array_slice($this->_data, $offset, $length);
     return \Gacela::instance()->makeCollection($this->_mapper, $data);
 }
Ejemplo n.º 12
0
 public function delete($id)
 {
     $model = Gacela::instance()->loadMapper('teacher')->find($id);
     $model->delete();
     $this->_redirect('/singleInheritance');
 }
Ejemplo n.º 13
0
 /**
  * @covers Gacela::makeCollection
  * @expectedException Gacela\Exception
  */
 public function testMakeCollectionThrowsException()
 {
     $mapper = new Test\Mapper\Peep();
     $this->object->makeCollection($mapper, new \ArrayObject());
 }
Ejemplo n.º 14
0
 public function delete($id)
 {
     $student = Gacela::instance()->loadMapper('student')->find($id);
     $student->delete();
     $this->_redirect('/concreteInheritance');
 }