当前位置: 首页>>代码示例>>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;未经允许,请勿转载。