public static function all($where_clause = []) { // Create an SQL "WHERE" clause $sql_where = Sql::where($where_clause); // SQL $sql = "\n SELECT * FROM " . static::$table . $sql_where; // Get Results $results = DB::select($sql, $where_clause); // Make Collection $collection = new Collection(); foreach ($results as $row) { // Create new Model $model = new static(); $model->setData($row->{static::$key}, (array) $row); // Add Model to Collection $collection->add($model); } return $collection; }
/** * Collect All */ public static function all($where_clause = []) { // Create an SQL "WHERE" clause $sql_where = Sql::where($where_clause); // SQL $sql = "\n SELECT * FROM " . static::$table . $sql_where; // Get Results $results = DB::select($sql, $where_clause); // Return a collection return self::makeCollection($results); }