當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::findAll方法代碼示例

本文整理匯總了PHP中app\models\User::findAll方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::findAll方法的具體用法?PHP User::findAll怎麽用?PHP User::findAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\User的用法示例。


在下文中一共展示了User::findAll方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionToday

 /**
  * Отравка сообщения о сегодняшних дедлайнах
  */
 public function actionToday()
 {
     $bot = new BotApi(Yii::$app->params['token']);
     $start = time();
     $end = strtotime('+1 day');
     $users = User::findAll(['notification' => true]);
     foreach ($users as $user) {
         $deadlines = [];
         foreach ($user->teams as $team) {
             $deadline = strtotime($team->tournament->deadline);
             if ($deadline > $start && $deadline < $end) {
                 $deadlines[$team->tournament->name] = $team->tournament->deadline;
             }
         }
         if (!empty($deadlines)) {
             asort($deadlines);
             $message = 'Сегодня дедлайны:';
             foreach ($deadlines as $name => $deadline) {
                 $date = new DateTime($deadline, new DateTimeZone(Yii::$app->timeZone));
                 $message .= "\n" . $date->format('H:i') . '  ' . $name;
             }
             try {
                 $bot->sendMessage($user->chat_id, $message);
             } catch (Exception $e) {
                 Yii::info($e->getMessage(), 'send');
             }
         }
     }
 }
開發者ID:AnisimovMoscow,項目名稱:fantasy-bot,代碼行數:32,代碼來源:TournamentsController.php

示例2: actionAll

 public function actionAll()
 {
     if (Yii::$app->user->identity->role != USER::ADMIN) {
         throw new ForbiddenHttpException("You are not allowed", 1);
     }
     $users = User::findAll(['status' => User::ACTIVE, 'role' => User::CLIENT]);
     return ['success' => 1, 'payload' => $users];
 }
開發者ID:aniruddhanath,項目名稱:yii2-rest-api,代碼行數:8,代碼來源:UserController.php

示例3: actionUsers

 /**
  * Remove new users that didn't validate the email for more than x days(read from config)
  * Removed deleted accounts if x days passed (read from config)
  */
 public function actionUsers()
 {
     $newUsers = User::findAll("status = :new AND register_date < DATE_SUB(NOW(), INTERVAL :days DAY)", array(':new' => User::STATUS_NEW, ':days' => GlobalConfig::value('USERS_REMOVE_NEW_AFTER_DAYS')));
     foreach ($newUsers as $user) {
         $this->debug($user->name . '<' . $user->email . '> deleted! [new]');
         $user->delete();
     }
     $deletedUsers = User::findAll("status = :deleted AND deleteblock_date < DATE_SUB(NOW(), INTERVAL :days DAY)", array(':deleted' => User::STATUS_DELETED, ':days' => GlobalConfig::value('USERS_REMOVE_DELETED_AFTER_X_DAYS')));
     foreach ($deletedUsers as $user) {
         $this->debug($user->name . '<' . $user->email . '> deleted! [delete request on ' . $user->deleteblock_date . ']');
         $user->delete();
     }
 }
開發者ID:mpf-soft,項目名稱:app-basic,代碼行數:17,代碼來源:Clean.php

示例4: actionTest

 public function actionTest()
 {
     // $user = new User();
     // $user->name = 'jun1';
     // $user->age = 30;
     // $result = $user->insert();
     // $user = User::findOne(['id' => 10]);
     // $user->name = 'test';
     // $result = $user->update();
     // $result = $user->delete();
     // var_dump($result);die;
     $user = User::findAll();
     // $user = User::deleteAll(['name' => 'jun1']);
     // // $user = User::updateAll(['age' => 21], ['age' => 20]);
     $data = ['first' => 'awesome-php-zh_CN', 'second' => 'simple-framework', 'user' => $user];
     echo $this->toJson($data);
 }
開發者ID:CraryPrimitiveMan,項目名稱:simple-framework,代碼行數:17,代碼來源:SiteController.php

示例5: actionHome

 public function actionHome()
 {
     if (YII_DEBUG) {
         error_log("[Site::Home]");
     }
     if (YII_DEBUG) {
         error_log('CLIENTS : ');
         $users = User::findAll(["user_type" => 0]);
         foreach ($users as $user) {
             error_log("user : " . json_encode($user->getAttributes()));
         }
         error_log('DRIVERS : ');
         $users = User::findAll(["user_type" => 1]);
         foreach ($users as $user) {
             error_log("user : " . json_encode($user->getAttributes()));
         }
     }
     return $this->render('index', ['content' => []]);
 }
開發者ID:alexletsu,項目名稱:kiytes,代碼行數:19,代碼來源:SiteController.php

示例6: testCreateModel

 public function testCreateModel()
 {
     $indonesia = new Country(array('name' => 'Indonesia'));
     $indonesia->save();
     $user = new User(array('fullname' => 'Mukhamad Ikhsan', 'email' => 'some.email@email.com', 'password' => 'rahasia', 'profile' => array('profession' => 'programmer', 'nationality' => $indonesia)));
     $this->assertEqual('Mukhamad Ikhsan', $user->fullname);
     $this->assertEqual('programmer', $user->profile->profession);
     $this->assertEqual('Indonesia', $user->profile->nationality->name);
     $this->assertTrue($user->save());
     $ikhsan = User::getRepository()->findOneBy(array('email' => 'some.email@email.com'));
     $users = User::findAll(array('where' => array('and' => array(array('fullname' => array('like' => '%Ikhsan')), array('fullname' => array('eq' => 'Mukhamad Ikhsan')), array('fullname' => array('neq' => 'Haris Riswandi')))), 'leftJoin' => array(array('field' => 'groups'))));
     $compacts = User::getCompactList('fullname');
     $this->assertEqual(1, count($users));
     $this->assertEqual(1, count($compacts));
     $this->assertEqual('Mukhamad Ikhsan', $ikhsan->fullname);
     $this->assertEqual('programmer', $ikhsan->profile->profession);
     $this->assertEqual('Indonesia', $ikhsan->profile->nationality->name);
     $ikhsan->delete();
     $indonesia->delete();
     $this->assertNull(User::getRepository()->findOneBy(array('email' => 'some.email@email.com')));
     $this->assertNull(Country::getRepository()->findOneBy(array('name' => 'Indonesia')));
 }
開發者ID:ncud,項目名稱:sagalaya,代碼行數:22,代碼來源:ModelTest.php

示例7: foo

<?php

require __DIR__ . '/autoload.php';
$users = \App\Models\User::findAll();
var_dump($users);
/**
echo \App\Models\User::$table;
*/
/**
$user = new   \App\Models\User();
$user->findAll();

var_dump($user->findAll());
*/
/**
$db = new \App\Db();
$data = $db->query('SELECT * FROM users','App\Models\User');
var_dump($data);
*/
/**
$db = new \App\Db();
$res = $db->execute('CREATE TABLE foo (id SERIAL)');
var_dump($res);
*/
開發者ID:Artwiser,項目名稱:php,代碼行數:24,代碼來源:index.php

示例8: getUserList

 public function getUserList()
 {
     return User::findAll(['created_time' => 0]);
 }
開發者ID:realphp,項目名稱:yii2-admin,代碼行數:4,代碼來源:YiiUser.php

示例9: actionDefault

 public function actionDefault()
 {
     $this->data->items = User::findAll();
 }
開發者ID:gembux2012,項目名稱:ksp.dem,代碼行數:4,代碼來源:Admin.php

示例10: actionBulkDelete

 /**
  * Delete multiple existing User model.
  * For ajax request will return json object
  * and for non-ajax request if deletion is successful, the browser will be redirected to the 'index' page.
  * @param string $id
  * @return mixed
  */
 public function actionBulkDelete()
 {
     $request = Yii::$app->request;
     $pks = $request->post('pks');
     // Array or selected records primary keys
     foreach (User::findAll(json_decode($pks)) as $model) {
         $model->delete();
     }
     if ($request->isAjax) {
         /*
          *   Process for ajax request
          */
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ['forceClose' => true, 'forceReload' => '#crud-datatable-pjax'];
     } else {
         /*
          *   Process for non-ajax request
          */
         return $this->redirect(['index']);
     }
 }
開發者ID:javierojeda94,項目名稱:sas_final,代碼行數:28,代碼來源:UserController.php

示例11: actionIndex

 protected function actionIndex()
 {
     $this->view->news = \App\Models\News::findLastNews(3);
     $this->view->users = \App\Models\User::findAll();
     echo $this->view->render(__DIR__ . '/../templates/index.php');
 }
開發者ID:mr-kamc,項目名稱:php2.zz,代碼行數:6,代碼來源:News.php

示例12: actionIndex

 protected function actionIndex()
 {
     $this->view->news = News::findLastNews(5);
     $this->view->users = User::findAll();
     echo $this->view->render(__DIR__ . '/../templates/admin.php');
 }
開發者ID:mr-kamc,項目名稱:php2.zz,代碼行數:6,代碼來源:Admin.php

示例13: dirname

<?php

require_once dirname(dirname(__DIR__)) . '/layout/header.php';
echo \mpf\widgets\datatable\Table::get(['dataProvider' => $model->getDataProvider(), 'columns' => ['url', 'author_id' => ['filter' => \mpf\helpers\ArrayHelper::get()->transform(\app\models\User::findAll(), ['id' => 'name']), 'value' => function (\mpf\modules\blog\models\BlogPost $model) {
    return $model->author->name;
}], 'category_id' => ['filter' => \mpf\helpers\ArrayHelper::get()->transform(\mpf\modules\blog\models\BlogCategory::findAll(), ['id' => 'name']), 'value' => function (\mpf\modules\blog\models\BlogPost $model) {
    return $model->category->name;
}], 'time_written' => ['class' => 'Date'], 'time_published' => ['class' => 'Date'], 'status' => ['filter' => \mpf\modules\blog\models\BlogPost::getStatuses(), 'value' => function (\mpf\modules\blog\models\BlogPost $model) {
    $all = \mpf\modules\blog\models\BlogPost::getStatuses();
    return $all[$model->status];
}], ['class' => 'Actions', 'buttons' => ['delete' => ['class' => 'Delete'], 'edit' => ['class' => 'Edit'], 'publish' => ['post' => ['{{modelKey}}' => '$row->id'], 'confirmation' => \app\components\htmltools\Translator::get()->t("Are you sure that you want to publish the article?"), 'title' => '"Publish Article"', 'url' => "\\mpf\\WebApp::get()->request()->createURL('articles', 'publish')", 'icon' => '%MPF_ASSETS%images/oxygen/%SIZE%/actions/view-task.png', 'visible' => "\$row->status != " . \mpf\modules\blog\models\BlogPost::STATUS_PUBLISHED]], 'headerHtmlOptions' => ['style' => 'width:60px;']]]])->display();
require_once dirname(dirname(__DIR__)) . '/layout/footer.php';
開發者ID:mpf-soft,項目名稱:social-modules,代碼行數:12,代碼來源:index.php

示例14: count

<?php

require __DIR__ . '/autoload.php';
$view = new \App\View();
$view->title = 'Мой крутой сайт!';
$view->users = \App\Models\User::findAll();
echo count($view);
die;
$view->display(__DIR__ . '/App/templates/index.php');
開發者ID:AlexPanich,項目名稱:php2-lessons,代碼行數:9,代碼來源:index.php

示例15: actionTest

 public function actionTest()
 {
     $user_m = User::findAll(['username' => '13699273824']);
     var_dump($user_m);
     exit;
 }
開發者ID:suibber,項目名稱:hutujizhang,代碼行數:6,代碼來源:WechatController.php


注:本文中的app\models\User::findAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。