本文整理汇总了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');
}
}
}
}
示例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];
}
示例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();
}
}
示例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);
}
示例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' => []]);
}
示例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')));
}
示例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);
*/
示例8: getUserList
public function getUserList()
{
return User::findAll(['created_time' => 0]);
}
示例9: actionDefault
public function actionDefault()
{
$this->data->items = User::findAll();
}
示例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']);
}
}
示例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');
}
示例12: actionIndex
protected function actionIndex()
{
$this->view->news = News::findLastNews(5);
$this->view->users = User::findAll();
echo $this->view->render(__DIR__ . '/../templates/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';
示例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');
示例15: actionTest
public function actionTest()
{
$user_m = User::findAll(['username' => '13699273824']);
var_dump($user_m);
exit;
}