Example #1
0
 /**
  *	Makes and executes a SQL query, based on various filters, orders, groups, and columns to return.
  *		@param string $table Table in which to search
  *		@param array $filters Filters to apply. Can be name=>value pair, SQL statement, or recursive array relating to conditions on other tables
  *		@param array $ordergroup How to order, group and limit the search
  *		@param array $columns What columns to return in search. You can pass key value pairs to retrieve values from other 
  * 	tables such as 'relatedTable'=>'column'
  * 		@param bool $import - whether to import the resulting stuff into tables or not. Default is true. Set to false if you 
  *  use the $columns parameter to retrieve values from other tables.
  *		@return array
  **/
 public function find($table, $filters = array(), $ordergroup = array(), $columns = array(), $import = TRUE)
 {
     $pK = self::$primaryKey[$this->table];
     if ($pK != false && isset($this->originalData[$pK])) {
         $filters[$pK] = $this->originalData[$pK];
         $filters = array($this->table => $filters);
     }
     $query = new Query($table, $filters, $ordergroup, $columns);
     $results = $this->connection->fetchAll($query->buildQuery());
     //return $results;
     if ($import) {
         return self::importRows($table, $results);
     } else {
         return $results;
     }
 }