public static function get_list($name, $deep = false, $where = array(), $order_by = null, $order_by_dir = 'ASC', $limit_offset = null, $limit = null) { $obj = Bamboo::factory($name); $query = DB::select()->from($obj->_table); if ($deep) { call_user_func_array(array($query, 'select'), array_keys($obj->_fields)); } else { call_user_func_array(array($query, 'select'), array($obj->__id_field, $obj->__name_field)); } foreach ($where as $key => $value) { $query->where($key, '=', $value); } if ($order_by) { $query->order_by($order_by, $order_by_dir); } else { if ($obj->_sort_on) { $query->order_by($obj->_sort_on); } } if ($limit_offset !== null && $limit !== null) { $query->offset($limit_offset)->limit($limit); } $results = array(); $result = $query->execute($obj->_db); while ($row = $result->current()) { array_push($results, Bamboo::factory($name, $row)); $result->next(); } return $results; }
public function get() { if (!isset($this->relatedModel)) { if (isset($this->value)) { $this->relatedModel = Bamboo::factory($this->model); $this->relatedModel->{$this->relatedModel->__id_field} = $this->raw(); $this->relatedModel->load(); } } return $this->relatedModel; }