/** * Find records by using a sql statement, avoid to use this method if you * can do it in another way (like using default find methods) * * @param $sql SQL Statement * @return array Array of objects returned by query */ public function find_by_sql($sql) { $data = DbCommand::all($sql); $data = array_map(array($this, 'map_object'), $data); foreach ($data as $model) { $model->_exists = true; } return $data; }