Пример #1
0
 function testCountAndInsert()
 {
     $t = new Naf_Table('test');
     $this->assertEqual(0, $t->count());
     $this->assertEqual(1, $t->insert(array('name' => 'test name')));
     $this->assertEqual(1, $t->count());
     $row = $t->find(1);
     $this->assertEqual('test name', $row['name']);
 }
Пример #2
0
 /**
  * Filter a field to be unique.
  *
  * @param string $field
  * @param mixed $value
  * @return mixed value of $value if it is unique, bool FALSE otherwise
  */
 protected function _filterUnique($field, $value)
 {
     $where = array($field . ' = ?' => $value);
     if (!empty($this->_data[$this->_pk])) {
         $where[$this->_tableName . '.' . $this->_pk . ' != ?'] = $this->_data[$this->_pk];
     }
     if ($this->_table->count($where)) {
         return false;
     }
     return $value;
 }