本文整理汇总了PHP中app\models\Object::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::find方法的具体用法?PHP Object::find怎么用?PHP Object::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Object
的用法示例。
在下文中一共展示了Object::find方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: down
public function down()
{
$objects = \app\models\Object::find()->asArray()->all();
foreach ($objects as $object) {
$this->dropColumn($object['eav_table_name'], 'property_group_id');
}
}
示例2: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = ObjectModel::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(['id' => $this->id]);
$query->andFilterWhere(['like', 'user_name', $this->user_name])->andFilterWhere(['like', 'auth', $this->auth])->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
示例3: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Object::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(['id' => $this->id, 'id_user' => $this->id_user, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status]);
$query->andFilterWhere(['like', 'title', $this->title]);
return $dataProvider;
}
示例4: getForClass
/**
* @param string $class_name
* @return null|\app\models\Object
*/
public static function getForClass($class_name)
{
if (isset(static::$ids_for_class_name[$class_name])) {
$id = static::$ids_for_class_name[$class_name];
return Object::findById($id);
} else {
$object = Yii::$app->cache->get('ObjectByClassName: ' . $class_name);
if ($object === false) {
$object = Object::find()->where(['object_class' => $class_name])->one();
if ($object !== null) {
Yii::$app->cache->set('ObjectByClassName: ' . $class_name, $object, 86400, new TagDependency(['tags' => [\devgroup\TagDependencyHelper\ActiveRecordHelper::getObjectTag($object, $object->id)]]));
}
}
if (is_object($object)) {
static::$identity_map[$object->id] = $object;
static::$ids_for_class_name[$class_name] = $object->id;
return static::$identity_map[$object->id];
}
}
return null;
}
示例5: actionIndex
/**
* @return string
*/
public function actionIndex()
{
$objects = new ActiveDataProvider(['query' => Object::find()->with(['lastExport', 'lastImport']), 'pagination' => ['pageSize' => 10], 'sort' => false]);
return $this->render('index', ['objects' => $objects]);
}
示例6: actionPosts
public function actionPosts()
{
if (!\Yii::$app->user->isGuest) {
$sort = new Sort(['attributes' => ['id' => ['label' => 'ID'], 'urlimg' => ['asc' => ['urlimg' => SORT_ASC], 'desc' => ['urlimg' => SORT_DESC], 'default' => SORT_ASC, 'label' => 'Картинка'], 'id_router' => ['asc' => ['id_router' => SORT_ASC], 'desc' => ['id_router' => SORT_DESC], 'default' => SORT_ASC, 'label' => 'ID Роутора'], 'created_at' => ['label' => 'Дата создания'], 'status' => ['label' => 'Статус']]]);
$arrayobject = array();
$arrayrouter = array();
if (Yii::$app->user->identity->role == 1) {
$modelsobject = Object::find()->where(['id_user' => Yii::$app->user->identity->id])->select(['id', 'title'])->all();
$n_object = 0;
if ($modelsobject != NULL) {
foreach ($modelsobject as $modelobject) {
$arrayobject[$n_object] = $modelobject->id;
$n_object++;
}
}
$modelsrouter = Router::find()->where(['id_object' => $arrayobject])->select(['id'])->all();
$n_router = 0;
if ($modelsrouter != NULL) {
foreach ($modelsrouter as $modelrouter) {
$arrayrouter[$n_router] = $modelrouter->id;
$n_router++;
}
}
$query = Post::find()->where(['id_router' => $arrayrouter])->orderBy($sort->orders);
}
if (Yii::$app->user->identity->role == 5) {
$modelsuser = Users::find()->where(['role' => 1, 'id_manager' => Yii::$app->user->identity->id])->select(['id'])->all();
if ($modelsuser != NULL) {
$n_user = 0;
$arrayuser = array();
foreach ($modelsuser as $modeluser) {
$arrayuser[$n_user] = $modeluser->id;
$n_user++;
}
}
$modelsobject = Object::find()->where(['id_user' => $arrayuser])->select(['id', 'title'])->all();
$n_object = 0;
if ($modelsobject != NULL) {
foreach ($modelsobject as $modelobject) {
$arrayobject[$n_object] = $modelobject->id;
$n_object++;
}
}
$modelsrouter = Router::find()->where(['id_object' => $arrayobject])->select(['id'])->all();
$n_router = 0;
if ($modelsrouter != NULL) {
foreach ($modelsrouter as $modelrouter) {
$arrayrouter[$n_router] = $modelrouter->id;
$n_router++;
}
}
$query = Post::find()->where(['id_router' => $arrayrouter])->orderBy($sort->orders);
}
if (Yii::$app->user->identity->role == 10) {
$query = Post::find()->orderBy($sort->orders);
}
$countQuery = clone $query;
$pages = new Pagination(['totalCount' => $countQuery->count()]);
$modelspost = $query->offset($pages->offset)->limit($pages->limit)->all();
return $this->render('posts', ['modelspost' => $modelspost, 'pages' => $pages, 'sort' => $sort]);
} else {
return $this->redirect(['login']);
}
}