Exemple #1
0
 protected function getTable($name = '')
 {
     if (empty($name)) {
         $name = get_class($this);
     }
     //if
     $table = new MingoTable($name);
     $table->setIndex('foobarbaz', array('foo', 'bar', 'baz'));
     $table->setField('foo', MingoField::TYPE_INT);
     $table->setIndex('barbaz', array('bar', 'baz'));
     return $table;
 }
Exemple #2
0
 /**
  *  get the table this class will use on the db side
  *  
  *  @return MingoTable
  */
 public function getTable()
 {
     // canary...
     if (!empty($this->table)) {
         return $this->table;
     }
     //if
     $table = new MingoTable($this->getTableName());
     // set some of the default fields...
     $table->setField(self::_CREATED, MingoField::TYPE_INT);
     $table->setField(self::_UPDATED, MingoField::TYPE_INT);
     // let some custom stuff be added...
     $this->populateTable($table);
     $this->setTable($table);
     return $this->table;
 }
Exemple #3
0
 /**
  *  assure right index is queried
  *  
  *  with 2 similar indexes using SQLite (and I assume MySQL) the interface's
  *  index table selector would mess up because it would choose the first table
  *  since the where would match and the sort was never taken into account, so a
  *  PDOException would be thrown:
  *  
  *  PDOException: SQLSTATE[HY000]: General error: 1 no such column: che
  *  
  *  this test is here to make sure that is fixed
  *  
  *  @since  9-2-11
  */
 public function testSimilarIndexes()
 {
     $db = $this->getDb();
     // create a more advanced table...
     $table = new MingoTable(__FUNCTION__);
     $table->setField('foo', MingoField::TYPE_STR);
     $table->setField('bar', MingoField::TYPE_STR);
     $table->setField('che', MingoField::TYPE_STR);
     // create 2 similar indexes...
     $table->setIndex('foo_and_bar', array('foo', 'bar'));
     $table->setIndex('foo_and_che', array('foo', 'che'));
     // make sure the table exists in the db
     $this->setTable($table);
     // now try and query the second index...
     $where_criteria = new MingoCriteria();
     $where_criteria->isFoo(__FUNCTION__);
     $where_criteria->descChe();
     // no errors should be thrown...
     $list = $db->get($table, $where_criteria);
     $this->assertEmpty($list);
 }