/** * This constructor instantiates this class using the specified model's name. * * @access public * @param string $model the model's name */ public function __construct($model) { $name = $model; $model = DB_ORM_Model::model_name($name); $this->data_source = DB_DataSource::instance($model::data_source(DB_DataSource::MASTER_INSTANCE)); $builder = 'DB_' . $this->data_source->dialect . '_Insert_Builder'; $this->builder = new $builder($this->data_source); $extension = DB_ORM_Model::builder_name($name); if (class_exists($extension)) { $this->extension = new $extension($this->builder); } $table = $model::table(); $this->builder->into($table); $this->model = $model; }
/** * This constructor instantiates this class using the specified model's name. * * @access public * @param string $model the model's name * @param array $columns the columns to be selected */ public function __construct($model, array $columns = array()) { $name = $model; $model = DB_ORM_Model::model_name($name); $this->data_source = DB_DataSource::instance($model::data_source(DB_DataSource::SLAVE_INSTANCE)); $builder = 'DB_' . $this->data_source->dialect . '_Select_Builder'; $this->table = $model::table(); $this->builder = new $builder($this->data_source, $columns); if (empty($columns)) { $this->builder->all("{$this->table}.*"); } $this->builder->from($this->table); $extension = DB_ORM_Model::builder_name($name); if (class_exists($extension)) { $this->extension = new $extension($this->builder); } $this->model = $model; }