Example #1
0
 function __construct()
 {
     parent::__construct();
     $c = new Naf_UnitTestDbConnection();
     $this->connection = $c->getConnection();
     Naf_Table::setDefaultConnection($this->connection);
 }
Example #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;
 }
Example #3
0
 /**
  * @param PDO $connection
  */
 static function setDefaultConnection($connection)
 {
     self::$defaultConnection = $connection;
 }
 /**
  * @return Naf_Table
  */
 private function loadDummyData()
 {
     $t = new Naf_Table('test');
     for ($i = 1; $i <= self::DUMMY_DATA_COUNT; ++$i) {
         $t->insert(array('name' => 'test' . $i));
     }
     return $t;
 }
Example #5
0
 /**
  * Get [sub]totals for numeric columns
  *
  * @param string | array $expressions
  * @return string | array
  */
 function sum($expressions)
 {
     return $this->_table->sum($expressions, $this->_filters);
 }