Created
June 1, 2010 13:42
-
-
Save zombor/420951 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Same as fetch_all except you can pass a where clause | |
* | |
* @param array $where the where clause | |
* @param string $order_by a column to order on | |
* @param string $direction the direction to sort | |
* @param string $type the type of where to run | |
* | |
* @return Database_Result | |
*/ | |
public function fetch_where($wheres = array(), $order_by = 'id', $direction = 'ASC', $type = 'and') | |
{ | |
$function = $type.'_where'; | |
$query = db::select('*')->order_by($order_by, $direction)->as_object('Model_'.inflector::singular(ucwords($this->_table_name))); | |
foreach ($wheres as $where) | |
$query->$function($where[0], $where[1], $where[2]); | |
return $query->execute($this->_db); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment