本文整理汇总了PHP中yii\base\Model::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::find方法的具体用法?PHP Model::find怎么用?PHP Model::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\base\Model
的用法示例。
在下文中一共展示了Model::find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildActiveQuery
/**
* @param string|array $condition
* @return BaseActiveQuery
*/
protected function buildActiveQuery($condition)
{
/** @var BaseActiveQuery $query */
$query = $this->model->find()->andWhere($condition);
if ($this->pagination instanceof Pagination) {
$query->offset($this->pagination->offset);
$query->limit($this->pagination->limit);
}
return $query;
}
示例2: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Model::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['doc_id' => $this->doc_id]);
$query->andFilterWhere(['like', 'zipcode', $this->zipcode]);
return $dataProvider;
}