Example #1
0
 public function testHaveAutoIncrement()
 {
     $tableDesc = new TableDesc('authors');
     $this->assertTrue($tableDesc->hasAutoIncrement());
 }
Example #2
0
File: Morm.php Project: anicet/morm
 /**
  * getTableDesc 
  *
  * returns the TableDesc of the model's table
  * 
  * @return TableDesc
  */
 public function getTableDesc()
 {
     return TableDesc::getTable($this->_table);
 }
Example #3
0
 static function singleWhere($table, $condition)
 {
     $field = array_keys($condition);
     $field = $field[0];
     $operator = '=';
     if (is_array($condition[$field]) && isset($condition[$field]['operator'])) {
         $operator = $condition[$field]['operator'];
         $condition[$field] = $condition[$field][0];
     }
     $table_desc = TableDesc::getTable($table);
     if (is_array($condition[$field])) {
         foreach ($condition[$field] as $key => $value) {
             settype($condition[$field][$key], $table_desc->{$field}->php_type);
         }
         $operator = 'IN';
         return '`' . $table . '`.`' . $field . '` ' . $operator . ' (' . SqlTools::formatSqlValue($condition[$field]) . ')';
     }
     settype($condition[$field], $table_desc->{$field}->php_type);
     return '`' . $table . '`.`' . $field . '` ' . $operator . ' ' . SqlTools::formatSqlValue($condition[$field]);
 }