classes/database.php
/**
	 * Fetch a single table row using the SQL given.
	 *
	 * @param string $sql query to run
	 * @param array $params for the prepared statement
	 * @param mixed $as_object name to return row as (FALSE for array)
	 * @param int $cache life of result set in seconds or FALSE to disable
	 * @return object|array
	 */
Fetch a single table row using the SQL given.
Fetch a single table row using the SQL given .
public function fetch_row($sql, array $params = array(), $as_object = TRUE, $cache = FALSE)
	{
		if($cache AND $results = $this->_cache($sql, $params))
		{
			return $results;
		}
		$result = $this->query($sql, $params);
		if (is_string($as_object))
		{
			$result = new $as_object($result->fetch(PDO::FETCH_ASSOC));
		}
		elseif($as_object === TRUE)
		{
			$result = $result->fetch(PDO::FETCH_OBJ);
		}
		else
		{
			$result = $result->fetch(PDO::FETCH_ASSOC);
		}
				if($result AND $cache)
		{
			cache::set($hash, $result);
		}
		return $result;
	}
public function fetch_row ( $ sql , array $ params = array ( ) , $ as_object = TRUE , $ cache = FALSE ) { if ( $ cache AND $ results = $ this -> _cache ( $ sql , $ params ) ) { return $ results ; } $ result = $ this -> query ( $ sql , $ params ) ; if ( is_string ( $ as_object ) ) { $ result = new $ as_object ( $ result -> fetch ( PDO :: FETCH_ASSOC ) ) ; } elseif ( $ as_object === TRUE ) { $ result = $ result -> fetch ( PDO :: FETCH_OBJ ) ; } else { $ result = $ result -> fetch ( PDO :: FETCH_ASSOC ) ; } if ( $ result AND $ cache ) { cache :: set ( $ hash , $ result ) ; } return $ result ; }
Fetch a single table row using the SQL given.
Fetch a single table row using the SQL given .
// Try to get the cached results first // Run the query // If we should fetch the results into an object // Should we cache the results?
