本文整理汇总了PHP中yii\data\ActiveDataProvider类的典型用法代码示例。如果您正苦于以下问题:PHP ActiveDataProvider类的具体用法?PHP ActiveDataProvider怎么用?PHP ActiveDataProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ActiveDataProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: existUser
public function existUser($post)
{
$model = new $this->modelClass();
$query = $model::find()->orFilterWhere(['login' => $post['login']])->orFilterWhere(['email' => $post['email']]);
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 5]]);
return $dataProvider->getCount() === 0 ? false : true;
}
示例2: actionApril
/**
* Список учителей, с которыми занимаются только ученики, родившиеся в апреле.
* @return mixed
*/
public function actionApril()
{
$title = 'Список учителей, с которыми занимаются только ученики, родившиеся в апреле';
$dataProvider = new ActiveDataProvider(['query' => Teacher::teachsOnlyAprilBornStudents()]);
$dataProvider->setSort(['defaultOrder' => ['name' => SORT_ASC], 'attributes' => ['name', 'gender', 'phone', 'students_count' => ['asc' => ['stud_cnt' => SORT_ASC], 'desc' => ['stud_cnt' => SORT_DESC]]]]);
return $this->render('index', ['dataProvider' => $dataProvider, 'title' => $title]);
}
示例3: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Lesson::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider(['query' => $query]);
$dataProvider->setSort(['attributes' => ['id', 'groupName' => ['asc' => ['group.name' => SORT_ASC], 'desc' => ['group.name' => SORT_DESC], 'label' => 'groupName'], 'disciplineName' => ['asc' => ['discipline.name' => SORT_ASC], 'desc' => ['discipline.name' => SORT_DESC], 'label' => 'disciplineName'], 'teacherFullname' => ['asc' => ['user.last_name' => SORT_ASC, 'user.first_name' => SORT_ASC, 'user.middle_name' => SORT_ASC], 'desc' => ['user.last_name' => SORT_DESC, 'user.first_name' => SORT_DESC, 'user.middle_name' => SORT_DESC], 'label' => 'teacherFullname'], 'lessonTypeName' => ['asc' => ['lesson_type.name' => SORT_ASC], 'desc' => ['lesson_type.name' => SORT_DESC], 'label' => 'lessonTypeName'], 'week', 'day', 'time', 'auditory']]);
$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;
}
// grid filtering conditions
$query->andFilterWhere(['id' => $this->id, 'ghd_id' => $this->ghd_id, 'lesson_type_id' => $this->lesson_type_id, 'week' => $this->week, 'day' => $this->day, 'time' => $this->time, 'date' => $this->date]);
$query->andFilterWhere(['like', 'auditory', $this->auditory]);
$query->joinWith('groupHasDiscipline')->joinWith(['groupHasDiscipline.group' => function ($q) {
$q->where('group.name LIKE "%' . $this->groupName . '%" ');
}]);
$query->joinWith('groupHasDiscipline')->joinWith(['groupHasDiscipline.discipline' => function ($q) {
$q->where('discipline.name LIKE "%' . $this->disciplineName . '%" ');
}]);
$query->joinWith('teacherHasDiscipline')->joinWith('teacherHasDiscipline.teacher')->joinWith(['teacherHasDiscipline.teacher.user' => function ($q) {
$q->where('user.first_name LIKE "%' . $this->teacherFullname . '%" ' . 'OR user.last_name LIKE "%' . $this->teacherFullname . '%"' . 'OR user.middle_name LIKE "%' . $this->teacherFullname . '%"');
}]);
$query->joinWith(['lessonType' => function ($q) {
$q->where('lesson_type.name LIKE "%' . $this->lessonTypeName . '%" ');
}]);
return $dataProvider;
}
示例4: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Comment::find()->select('comment.*, video.title, user.username')->innerJoin('video', '`video`.`id` = `comment`.`video_id`')->innerJoin('user', '`user`.`id` = `comment`.`user_id`');
// echo $query->createCommand()->sql;exit;
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->params['pageSize']]]);
/**
* Setup your sorting attributes
* Note: This is setup before the $this->load($params)
* statement below
*/
$dataProvider->setSort(['attributes' => ['id', 'text' => ['asc' => ['comment.text' => SORT_ASC], 'desc' => ['comment.text' => SORT_DESC]], 'videoTitle' => ['asc' => ['video.title' => SORT_ASC], 'desc' => ['video.title' => SORT_DESC]], 'username' => ['asc' => ['user.username' => SORT_ASC], 'desc' => ['user.username' => SORT_DESC]], 'created_at' => ['asc' => ['comment.created_at' => SORT_ASC], 'desc' => ['comment.created_at' => SORT_DESC]]]]);
$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;
}
/* ---------------------------------------------------------------------/
* Filter
* --------------------------------------------------------------------- */
$query->andFilterWhere(['comment.id' => $this->id, 'comment.video_id' => $this->video_id, 'comment.user_id' => $this->user_id, 'comment.created_at' => $this->created_at, 'comment.modified_at' => $this->modified_at]);
$query->andFilterWhere(['like', 'text', $this->text]);
/**
* for related column
*/
$query->andFilterWhere(['like', 'video.title', $this->videoTitle]);
$query->andFilterWhere(['like', 'user.username', $this->username]);
return $dataProvider;
}
示例5: search
public function search($params)
{
$query = group::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$dataProvider->setSort(['defaultOrder' => ['parentId' => SORT_ASC, 'name' => SORT_ASC]]);
$query->andFilterWhere([group::tableName() . '.status' => '1']);
if (!($this->load($params) && $this->validate())) {
$query->joinWith(['parent']);
return $dataProvider;
}
/*$query->andFilterWhere([
'Id' => $this->Id,
'createdon' => $this->createdon,
]);//*/
$query->andFilterWhere(['like', group::tableName() . '.name', $this->name]);
//->andFilterWhere(['like', 'parentId', $this->ParentGroup])
//->andFilterWhere(['like', 'status', $this->status]);
if ($this->parentGroup != '' && strtolower($this->parentGroup) != 'root') {
$query->joinWith(['parent' => function ($q) {
$q->where('parent.name LIKE "%' . $this->parentGroup . '%" ');
}]);
} else {
if (strtolower($this->parentGroup) == 'root') {
$query->andFilterWhere([group::tableName() . '.parentId' => 0]);
}
}
return $dataProvider;
}
示例6: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params, $newquery = null)
{
$query = GroupHasDiscipline::find();
if ($newquery) {
$query = $newquery;
}
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider(['query' => $query]);
$dataProvider->setSort(['attributes' => ['id', 'semester_number', 'semesterNumber' => ['asc' => ['group_semesters.semester_number' => SORT_ASC], 'desc' => ['group_semesters.semester_number' => SORT_DESC]], 'groupName' => ['asc' => ['group.name' => SORT_ASC], 'desc' => ['group.name' => SORT_DESC]], 'disciplineName' => ['asc' => ['discipline.name' => SORT_ASC], 'desc' => ['discipline.name' => SORT_DESC]]]]);
$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;
}
// grid filtering conditions
$query->andFilterWhere(['id' => $this->id, 'discipline_id' => $this->discipline_id, 'group_id' => $this->group_id, 'group_has_discipline.semester_number' => $this->semester_number]);
$query->joinWith(['semester' => function ($q) {
$q->where('group_semesters.semester_number LIKE "%' . $this->semesterNumber . '%" ');
}]);
$query->joinWith(['group' => function ($q) {
$q->where('group.name LIKE "%' . $this->groupName . '%" ');
}]);
$query->joinWith(['discipline' => function ($q) {
$q->where('discipline.name LIKE "%' . $this->disciplineName . '%" ');
}]);
return $dataProvider;
}
示例7: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Work::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$dataProvider->setSort(['attributes' => ['id', 'studentFullname' => ['asc' => ['user.last_name' => SORT_ASC], 'desc' => ['user.last_name' => SORT_DESC], 'label' => 'studentFullname'], 'groupName' => ['asc' => ['student.group.name' => SORT_ASC], 'desc' => ['student.group.name' => SORT_DESC], 'label' => 'groupName'], 'disciplineName' => ['asc' => ['groupHasDiscipline.discipline.name' => SORT_ASC], 'desc' => ['groupHasDiscipline.discipline.name' => SORT_DESC]]]]);
$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, 'work_type_id' => $this->work_type_id, 'name' => $this->name, 'student_id' => $this->student_id, 'teacher_id' => $this->teacher_id, 'date' => $this->date, 'approve_status' => $this->approve_status]);
$query->joinWith('student')->joinWith(['student.user' => function ($q) {
$q->where('user.first_name LIKE "%' . $this->studentFullname . '%" ' . 'OR user.last_name LIKE "%' . $this->studentFullname . '%"' . 'OR user.middle_name LIKE "%' . $this->studentFullname . '%"');
}]);
$query->joinWith('student')->joinWith(['student.group' => function ($q) {
$q->where('group.name LIKE "%' . $this->groupName . '%" ');
}]);
if ($this->work_type_id == Work::TYPE_TERM) {
$query->joinWith('groupHasDiscipline')->joinWith(['groupHasDiscipline.discipline' => function ($q) {
$q->where('discipline.name LIKE "%' . $this->disciplineName . '%" ');
}]);
}
return $dataProvider;
}
示例8: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = User::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
/**
* Setup your sorting attributes
* Note: This is setup before the $this->load($params)
* statement below
*/
$dataProvider->setSort(['attributes' => ['id', 'userIdLink' => ['asc' => ['user.id' => SORT_ASC], 'desc' => ['user.id' => SORT_DESC], 'label' => 'ID'], 'userLink' => ['asc' => ['user.username' => SORT_ASC], 'desc' => ['user.username' => SORT_DESC], 'label' => 'User'], 'perfilLink' => ['asc' => ['perfil.id' => SORT_ASC], 'desc' => ['perfil.id' => SORT_DESC], 'label' => 'Perfil'], 'rolNombre' => ['asc' => ['rol.rol_name' => SORT_ASC], 'desc' => ['rol.rol_name' => SORT_DESC], 'label' => 'Rol'], 'estadoNombre' => ['asc' => ['estado.estado_nombre' => SORT_ASC], 'desc' => ['estado.estado_nombre' => SORT_DESC], 'label' => 'Estado'], 'created_at' => ['asc' => ['created_at' => SORT_ASC], 'desc' => ['created_at' => SORT_DESC], 'label' => 'Created At'], 'email' => ['asc' => ['email' => SORT_ASC], 'desc' => ['email' => SORT_DESC], 'label' => 'Email']]]);
if (!($this->load($params) && $this->validate())) {
$query->joinWith(['rol'])->joinWith(['estado'])->joinWith(['perfil']);
return $dataProvider;
}
$this->addSearchParameter($query, 'id');
$this->addSearchParameter($query, 'username', true);
$this->addSearchParameter($query, 'email', true);
$this->addSearchParameter($query, 'rol_id');
$this->addSearchParameter($query, 'estado_id');
$this->addSearchParameter($query, 'created_at');
$this->addSearchParameter($query, 'updated_at');
// filter by role
$query->joinWith(['rol' => function ($q) {
$q->andFilterWhere(['=', 'rol.rol_nombre', $this->rolNombre]);
}])->joinWith(['estado' => function ($q) {
$q->andFilterWhere(['=', 'estado.estado_nombre', $this->estadoNombre]);
}])->joinWith(['perfil' => function ($q) {
$q->andFilterWhere(['=', 'perfil.id', $this->perfilId]);
}]);
return $dataProvider;
}
示例9: search
/**
* @param array $params Search conditions.
* @return ActiveDataProvider
*/
public function search($params)
{
$translateLanguage = Yii::$app->request->get('language_id', Yii::$app->sourceLanguage);
$sourceLanguage = $this->_getSourceLanguage();
$query = LanguageSource::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$dataProvider->setSort(['attributes' => ['id', 'category', 'message', 'translation' => ['asc' => ['lt.translation' => SORT_ASC], 'desc' => ['lt.translation' => SORT_DESC], 'label' => Yii::t('language', 'Translation')]]]);
if (!($this->load($params) && $this->validate())) {
$query->joinWith(['languageTranslate' => function ($query) use($translateLanguage) {
$query->from(['lt' => LanguageTranslate::tableName()])->onCondition(['lt.language' => $translateLanguage]);
}]);
$query->joinWith(['languageTranslateByLanguage' => function ($query) use($sourceLanguage) {
$query->from(['ts' => LanguageTranslate::tableName()])->onCondition(['ts.language' => $sourceLanguage]);
}]);
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'category' => $this->category]);
$query->andFilterWhere(['or', $this->createLikeExpression('message', $this->message), $this->createLikeExpression('ts.translation', $this->message)]);
$query->joinWith(['languageTranslate' => function ($query) use($translateLanguage) {
$query->from(['lt' => LanguageTranslate::tableName()])->onCondition(['lt.language' => $translateLanguage])->andFilterWhere($this->createLikeExpression('lt.translation', $this->translation));
}]);
$query->joinWith(['languageTranslateByLanguage' => function ($query) use($sourceLanguage) {
$query->from(['ts' => LanguageTranslate::tableName()])->onCondition(['ts.language' => $sourceLanguage]);
}]);
return $dataProvider;
}
示例10: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = User::find()->joinWith('profile');
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 50]]);
$dataProvider->setSort(['attributes' => ['id', 'username', 'email', 'super_admin', 'last_login', 'profile.firstname', 'profile.lastname', 'created_at']]);
$this->load($params);
if (!$this->validate()) {
$query->where('0=1');
return $dataProvider;
}
if (strtolower($this->last_login) == 'yes') {
$query->andWhere(['not', ['last_login' => null]]);
} else {
if (strtolower($this->last_login) == 'no') {
$query->andWhere(['last_login' => null]);
}
}
$query->andFilterWhere(['id' => $this->id]);
$query->andFilterWhere(['super_admin' => $this->super_admin]);
$query->andFilterWhere(['like', 'id', $this->id]);
$query->andFilterWhere(['like', 'username', $this->username]);
$query->andFilterWhere(['like', 'email', $this->email]);
$query->andFilterWhere(['like', 'profile.firstname', $this->getAttribute('profile.firstname')]);
$query->andFilterWhere(['like', 'profile.lastname', $this->getAttribute('profile.lastname')]);
return $dataProvider;
}
示例11: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
//$query = REFERRALGIVEN::find();
$query = REFERRALGIVEN::find()->joinWith(['rEFERRAL']);
$dataProvider = new ActiveDataProvider(['query' => $query]);
/**
* Setup your sorting attributes
* Note: This is setup before the $this->load($params)
* statement below
*/
$dataProvider->setSort(['attributes' => ['GIVEN_ID', 'MEMBER_ID', 'referralName' => ['asc' => ['REFERRAL.REFERRAL_NAME' => SORT_ASC], 'desc' => ['REFERRAL.REFERRAL_NAME' => SORT_DESC], 'label' => 'Referral Name'], 'MEETING_ID']]);
if (!($this->load($params) && $this->validate())) {
//Brad
//$query->joinWith(['rEFERRAL']);
return $dataProvider;
}
$query->andFilterWhere(['GIVEN_ID' => $this->GIVEN_ID, 'MEMBER_ID' => $this->MEMBER_ID, 'REFERRAL_ID' => $this->REFERRAL_ID, 'MEETING_ID' => $this->MEETING_ID]);
$query->andFilterWhere(['like', 'GIVEN_YOUR_CARD', $this->GIVEN_YOUR_CARD])->andFilterWhere(['like', 'TOLD_THEM_YOU_WOULD_CALL', $this->TOLD_THEM_YOU_WOULD_CALL])->andFilterWhere(['like', 'COMMENTS', $this->COMMENTS]);
// filter by Referral name - Brad
// $query->joinWith(['rEFERRAL'=>function ($q) {
// $q->where('rEFERRAL.REFERRAL_NAME LIKE "%' .
// $this->referralName . '%"');
// }]);
return $dataProvider;
}
示例12: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = User::find()->joinWith('profile');
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 50]]);
$dataProvider->setSort(['attributes' => ['id', 'username', 'email', 'super_admin', 'last_login', 'profile.firstname', 'profile.lastname', 'created_at']]);
$this->load($params);
if (!$this->validate()) {
$query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id]);
$query->andFilterWhere(['super_admin' => $this->super_admin]);
$query->andFilterWhere(['like', 'id', $this->id]);
$query->andFilterWhere(['like', 'username', $this->username]);
$query->andFilterWhere(['like', 'email', $this->email]);
$query->andFilterWhere(['like', 'profile.firstname', $this->getAttribute('profile.firstname')]);
$query->andFilterWhere(['like', 'profile.lastname', $this->getAttribute('profile.lastname')]);
if ($this->getAttribute('last_login') != "") {
try {
$last_login = Yii::$app->formatter->asDate($this->getAttribute('last_login'), 'php:Y-m-d');
$query->andWhere(['=', new \yii\db\Expression("DATE(last_login)"), new \yii\db\Expression("DATE(:last_login)", [':last_login' => $last_login])]);
} catch (InvalidParamException $e) {
// do not change the query if the date is wrong formatted
}
}
return $dataProvider;
}
示例13: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Books::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
/**
* Настройка параметров сортировки
* Важно: должна быть выполнена раньше $this->load($params)
* statement below
*/
$dataProvider->setSort(['attributes' => ['id', 'name', 'author' => ['asc' => ['lastname' => SORT_ASC, 'firstname' => SORT_ASC], 'desc' => ['lastname' => SORT_DESC, 'firstname' => SORT_DESC], 'default' => SORT_ASC], 'date', 'date_create']]);
$query->joinWith(['authors']);
if (!($this->load($params) && $this->validate())) {
/**
* Жадная загрузка данных модели Страны
* для работы сортировки.
*/
return $dataProvider;
}
$query->andFilterWhere(['books.id' => $this->id, 'author_id' => $this->author_id]);
$query->andFilterWhere(['like', 'name', $this->name]);
// Фильтр по полному имени
$query->andWhere('authors.firstname LIKE "%' . $this->author . '%" ' . 'OR authors.lastname LIKE "%' . $this->author . '%"');
// Фильтр по дате
/*
// Если на форме нужно воодить как на плейсхолдере
$myDateTime= DateTime::createFromFormat('d/m/Y', $this->date_begin);
$myDateTime->format('Y-m-d');
*/
$query->andFilterWhere(['>=', 'date', $this->date_begin]);
$query->andFilterWhere(['<=', 'date', $this->date_end]);
return $dataProvider;
}
示例14: prepareDataProvider
/**
* Prepares the data provider that should return the requested collection of the models.
* @return ActiveDataProvider
*/
protected function prepareDataProvider()
{
if ($this->prepareDataProvider !== null) {
return call_user_func($this->prepareDataProvider, $this);
}
/**
* @var \yii\db\BaseActiveRecord $modelClass
*/
$modelClass = $this->modelClass;
$searchClass = new EventSearch();
$query = $modelClass::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$dataProvider->setSort(['defaultOrder' => ['updatedOn' => SORT_DESC]]);
$query->andWhere("not ((`state`=" . AppActiveRecord::STATUS_DRAFT . ") AND (`createdBy`!=" . \yii::$app->user->id . "))");
if (!($searchClass->load(Yii::$app->request->queryParams, '') && $searchClass->validate())) {
$query->andFilterWhere(['NOT', ['state' => AppActiveRecord::STATUS_DELETE]]);
return $dataProvider;
}
if ($searchClass->state !== null) {
if ($searchClass->state == AppActiveRecord::STATUS_DRAFT) {
$query->andFilterWhere(['state' => $this->state, 'createdBy' => \yii::$app->user->id]);
} else {
$query->andFilterWhere(['state' => $searchClass->state]);
}
} else {
$query->andFilterWhere(['NOT', ['state' => AppActiveRecord::STATUS_DELETE]]);
}
$query->andFilterWhere(['Id' => $searchClass->Id, 'sourceId' => $searchClass->sourceId, 'cityId' => $searchClass->cityId, 'zoneId' => $searchClass->zoneId, 'localityId' => $searchClass->localityId, 'gpsLat' => $searchClass->gpsLat, 'gpsLong' => $searchClass->gpsLong, 'startDate' => $searchClass->startDate, 'endDate' => $searchClass->endDate, 'startTime' => $searchClass->startTime, 'endTime' => $searchClass->endTime, 'status' => $searchClass->status, 'isRecursive' => $searchClass->isRecursive, 'healthStatus' => $searchClass->healthStatus, 'createdOn' => $searchClass->createdOn, 'createdBy' => $searchClass->createdBy, 'updatedOn' => $searchClass->updatedOn, 'updatedBy' => $searchClass->updatedBy]);
$query->andFilterWhere(['like', 'categoryId', $searchClass->categoryId])->andFilterWhere(['like', 'name', $searchClass->name])->andFilterWhere(['like', 'description', $searchClass->description])->andFilterWhere(['like', 'address', $searchClass->address])->andFilterWhere(['like', 'landmark', $searchClass->landmark])->andFilterWhere(['like', 'pincode', $searchClass->pincode])->andFilterWhere(['like', 'tollfree', $searchClass->tollfree])->andFilterWhere(['like', 'contactName', $searchClass->contactName])->andFilterWhere(['like', 'email', $searchClass->email])->andFilterWhere(['like', 'url', $searchClass->url])->andFilterWhere(['like', 'shopurl', $searchClass->shopurl])->andFilterWhere(['like', 'price', $searchClass->price])->andFilterWhere(['like', 'ip', $searchClass->ip])->andFilterWhere(['like', 'recursionData', $searchClass->recursionData])->andFilterWhere(['like', 'oldGuid', $searchClass->oldGuid])->andFilterWhere(['like', 'guid', $searchClass->guid])->andFilterWhere(['like', 'multipleTimings', $searchClass->multipleTimings])->andFilterWhere(['like', 'weekdaysChecklist', $searchClass->weekdaysChecklist]);
/*$query->joinWith('eventMap')->andFilterWhere(['like', 'phone', $this->phone])
->andFilterWhere(['like', 'mobile', $this->mobile]);//*/
return $dataProvider;
}
示例15: actionSearch
/**
* Lists all Applyjobs models.
* @return mixed
*/
public function actionSearch()
{
$data = Yii::$app->request->post();
$longitude = $data['longitude'];
$latitude = $data['latitude'];
$query = (new \yii\db\Query())->select('daters.*,users.phone,users.nickname,users.thumb,hobbies.hobby')->from('daters')->orderBy(sprintf('abs(daters.longitude - %f) + abs(daters.latitude - %f)', $longitude, $latitude))->join('INNER JOIN', 'users', 'daters.userid = users.id')->join('INNER JOIN', 'hobbies', 'daters.hobbyid = hobbies.id');
$dataProvider = new ActiveDataProvider(['query' => $query]);
//$this->load($params);
//$value = 0;
if (!empty($data)) {
if (isset($data['phone'])) {
$query->andFilterWhere(['users.phone' => $data['phone']]);
}
if (isset($data['hobbyid'])) {
$query->andFilterWhere(['hobbyid' => $data['hobbyid']]);
}
if (isset($data['content'])) {
$query->andFilterWhere(['like', 'content', $data['content']]);
}
}
$daters = $dataProvider->getModels();
//$result = array ();
//$result ['item'] = array ();
//$tbreplys = (new \yii\db\Query ())->select('tbreplys.*,users.phone,users.nickname,users.thumb')->orderBy ( "tbreplys.created_at desc" )->join ( 'INNER JOIN', 'users', ' tbmessages.userid =users.id ')->where('tbreplys.messageid in ');
foreach ($daters as $i => $dater) {
$info = $dater;
$info["distance"] = $this->getDistance($latitude, $longitude, $info['latitude'], $info['longitude']);
$daters[$i] = $info;
}
$dataProvider->setModels($daters);
return $dataProvider;
}