function testCount(){ $sqlobj = new Query_Select($this->table,$this->fields); $testString = "SELECT count(*) as c FROM {$this->table} WHERE testTable.testid = :testid"; $testValues = array(':testid' => '12'); $sql->where(array('testid' => '12'))->count(); list($sql, $values) = $sqlobj->give_sql_and_values(); $this->assertEquals($testString, (string) $sql); $this->assertEquals($testValues, $values); }
public function execute(){ $cache_key = MemoryObjectStore::gen_key(array($this->build_sql(), $this->build_sql_values())); if(!$this->reload) $cache = MemoryObjectStore::get($cache_key); if (!empty($cache)) { return $cache; } else { $result = parent::execute(); if(is_array($result)){ foreach ($result as $result_key=>$result_val) { foreach ($this->additions as $key => $val) { $result[$result_key]->$key = $val; } } } else { foreach ($this->additions as $key => $val) { $result->$key = $val; } } MemoryObjectStore::put($cache_key, $result); } return $result; }
/** * Select data from the database * * @param string $table * @param array $fields * @param string $handler * @return mixed */ public static function select($table, $fields = array(), $handler = null) { return Query_Select::create($table, $handler)->fields($fields); }