/** * Constructor. * @param mixed $modelClass the model class (e.g. 'Post') or the model finder instance * (e.g. <code>Post::model()</code>, <code>Post::model()->published()</code>). * @param array $config configuration (name=>value) to be applied as the initial property values of this class. * @since v1.0 */ public function __construct($modelClass, $config = array()) { if (is_string($modelClass)) { $this->modelClass = $modelClass; $this->model = NParse::model($modelClass); } else { if ($modelClass instanceof NParse) { $this->modelClass = get_class($modelClass); $this->model = $modelClass; } } //$this->_criteria = $this->model->getDbCriteria(); //$this->_criteria = new NParseCriteria; if (isset($config['criteria'])) { $this->setCriteria($config['criteria']); //$pagination->setItemCount($this->getTotalItemCount()); // $this->_criteria->setLimit($pagination->getLimit()); //$this->_criteria->setOffset=$pagination->getOffset(); // $this->_criteria->_limit=$pagination->getLimit(); //$this->_criteria->_offset=$pagination->getOffset(); //$c=$this->_criteria->getConditions(); /* echo "<pre>"; print_r($c); echo "</pre>"; exit; */ $this->_criteria->mergeWith($config['criteria']); unset($config['criteria']); } $this->setId($this->modelClass); foreach ($config as $key => $value) { $this->{$key} = $value; } if ($this->keyField !== null) { if (is_array($this->keyField)) { throw new CException('This DataProvider cannot handle multi-field primary key!'); } } else { $this->keyField = 'id'; } }
/** * Returns the static model of the specified AR class. * @param string $className active record class name. * @return Test the static model class */ public static function model($className = __CLASS__) { return parent::model($className); }