예제 #1
0
	public function dbDataTable($id = null, Atomik_Db_Query $query = null, $options = array())
	{
		$this->dataTable($id, array(), $options);
		
		if ($this->options['sortColumn']) {
			$query->orderBy($this->options['sortColumn'], $this->options['sortOrder']);
		}
		
		$countQuery = clone $query;
		$result = $countQuery->count()->execute();
		$numberOfRows = $result->fetchColumn();
		$result->closeCursor();
		
		$this->options['paginateData'] = false;
		$this->options['sortData'] = false;
		$this->options['numberOfRows'] = $numberOfRows;
		
		$offset = ($this->options['currentPage'] - 1) * $this->options['rowsPerPage'];
		$query->limit($offset, $this->options['rowsPerPage']);
		
		$this->setData($query->execute());
		
		return $this;
	}
예제 #2
0
	/**
	 * Executes a query.
	 * Uses the cache version if available
	 * 
	 * @param	Atomik_Db_Query		$query
	 * @return 	Atomik_Db_Query_Result
	 */
	protected function _executeQuery(Atomik_Db_Query $query)
	{
		$hash = $query->toHash();
		if ($this->_queryCacheEnabled && isset($this->_queryCache[$hash])) {
			$this->_queryCache[$hash]->rewind();
			return $this->_queryCache[$hash];
		}
		
		if (($result = $query->execute()) === false) {
			return false;
		}
		
		if ($this->_queryCacheEnabled) {
			$this->_queryCache[$hash] = $result;
			return $this->_queryCache[$hash];
		}
		return $result;
	}
예제 #3
0
	/**
	 * Re-executes the query and refreshes the result
	 */
	public function reload()
	{
		$this->_query->execute(null, true, $this);
	}