本文整理汇总了PHP中Users::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::find方法的具体用法?PHP Users::find怎么用?PHP Users::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Users
的用法示例。
在下文中一共展示了Users::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionUp
public function actionUp($type, $id)
{
$ret_val = false;
$existing = new Rating();
$existing->queryOptions['user_id'] = \Yii::$app->user->getId();
$existing->queryOptions['remote_type'] = $type;
$existing->queryOptions['remote_id'] = $id;
switch ($existing->exists()) {
case false:
$model = new Rating(['remote_type' => $type, 'remote_id' => $id]);
$model->save();
break;
default:
$existing = new Rating();
$existing->queryOptions['remote_type'] = $type;
$existing->queryOptions['remote_id'] = $id;
$count = $existing->getCount();
switch (1) {
case $count < Users::find()->count():
$ret_val = true;
break;
}
break;
}
$this->renderResponse($ret_val);
}
示例2: indexAction
public function indexAction()
{
$this->view->users = Users::find();
$user = new Users();
$user->id = 3;
$user->save();
}
示例3: actionChangeInfo
/**
* 修改个人信息
*/
function actionChangeInfo()
{
$this->_pathway->addStep('个人信息');
$currentUser = $this->_app->currentUser();
$user = Users::find()->getById($currentUser['id']);
$form = new Form_User(url('admin::usercenter/changeInfo'));
$form->element('username')->set('readonly', 'true');
$form->remove('password');
$form->element('group_id')->items = Groups::find('id=?', $user->group_id)->order('weight desc')->getAll()->toHashMap('id', 'name');
$form->element('level_id')->items = Levels::find('weight=?', $user->level_id)->order('weight desc')->getAll()->toHashMap('weight', 'name');
$form->remove('enabled');
$form->add(QForm::ELEMENT, 'id', array('_ui' => 'hidden', 'value' => $currentUser['id']));
if ($this->_context->isPOST() && $form->validate($_POST)) {
try {
$user->changeProps($form->values());
$user->save();
return "{msg:'编辑成功'}";
} catch (QDB_ActiveRecord_ValidateFailedException $ex) {
$form->invalidate($ex);
}
} else {
$form->import($user);
}
$form->add(QForm::ELEMENT, 'reg_at', array('_ui' => 'textbox', '_label' => '注册时间', 'value' => date('Y-m-d', $user->register_at), 'class' => 'txt w200', 'readonly' => 'true'));
$form->add(QForm::ELEMENT, 'reg_ip', array('_ui' => 'textbox', '_label' => '注册IP', 'value' => $user->register_ip, 'class' => 'txt w200', 'readonly' => 'true'));
$form->add(QForm::ELEMENT, 'log_at', array('_ui' => 'textbox', '_label' => '最后登录时间', 'value' => $user->login_at == 0 ? '0000-00-00' : date('Y-m-d', $user->login_at), 'class' => 'txt w200', 'readonly' => 'true'));
$form->add(QForm::ELEMENT, 'log_ip', array('_ui' => 'textbox', '_label' => '最后登录IP', 'value' => $user->login_ip, 'class' => 'txt w200', 'readonly' => 'true'));
$form->add(QForm::ELEMENT, 'log_count', array('_ui' => 'textbox', '_label' => '登录次数', 'value' => $user->login_count, 'class' => 'txt w200', 'readonly' => 'true'));
$this->_view['form'] = $form;
}
示例4: groupsAction
public function groupsAction()
{
$this->view->title = "Sending Groups - ";
$this->view->selectmenu = "mgroups";
$groups = Users::aggregate(array('$group' => array('_id' => '$group')));
$this->view->kel = $groups['result'];
if ($this->request->isPost()) {
$groups = $this->request->getPost('group');
$responses = '';
foreach ($groups as $group) {
$userslist = Users::find(array(array('group' => $group)));
$rcpt = "";
foreach ($userslist as $user) {
if (!$rcpt) {
$rcpt = $user->num;
} else {
$rcpt = $rcpt . ',' . $user->num;
}
}
$response = $this->smsweb->sendSMS($rcpt, $this->request->getPost('msg'));
$responses = $responses . "\n" . $response;
}
return $this->dispatcher->forward(array('action' => 'sent', 'params' => array($this->view->title, $this->view->selectmenu, $responses)));
}
}
示例5: indexAction
/**
* Index action
*/
public function indexAction()
{
$numberPage = 1;
$list = Users::find();
$paginator = new Paginator(array("data" => $list, "limit" => 10, "page" => $numberPage));
$this->view->page = $paginator->getPaginate();
}
示例6: login
public static function login()
{
// get posted data
$post = Input::post(array('user', 'pass', 'remember'));
$errors = array();
if (empty($post['user'])) {
$errors[] = 'Please enter your username';
}
if (empty($post['pass'])) {
$errors[] = 'Please enter your password';
}
if (empty($errors)) {
// find user
if ($user = Users::find(array('username' => $post['user']))) {
// check password
if (crypt($post['pass'], $user->password) != $user->password) {
$errors[] = 'Incorrect details';
}
} else {
$errors[] = 'Incorrect details';
}
}
if (count($errors)) {
Notifications::set('error', $errors);
return false;
}
// if we made it this far that means we have a winner
Session::set('user', $user);
return true;
}
示例7: addAction
/**
* The add action
*/
public function addAction()
{
$auth = $this->session->get('auth');
if ($auth) {
$this->_bc->add('Add', 'awards/add');
$allEpisodes = Episodes::find(array('order' => 'air_date DESC'));
$allUsers = Users::find(array('order' => 'username'));
$allPlayers = Players::find(array('order' => 'active DESC, name'));
$this->view->setVar('users', $allUsers);
$this->view->setVar('episodes', $allEpisodes);
$this->view->setVar('players', $allPlayers);
if ($this->request->isPost()) {
$datetime = date('Y-m-d H:i:s');
$award = new Awards();
$award->userId = $this->request->getPost('user_id', 'int');
$award->episodeId = $this->request->getPost('episode_id', 'int');
$award->playerId = $this->request->getPost('player_id', 'int');
$award->award = $this->request->getPost('award', 'int');
if (!$award->save()) {
foreach ($award->getMessages() as $message) {
$this->flash->error((string) $message);
}
} else {
$this->view->disable();
$this->flash->success('Award created successfully');
$this->invalidateCache();
$this->response->redirect('awards/');
}
}
}
}
示例8: destroy
public function destroy($id)
{
$users = Users::find($id);
$users->delete();
Session::flash('message', 'Successfully deleted the Users!');
return Redirect::to('users');
}
示例9: indexAction
public function indexAction()
{
$this->view->title = "Outbox - ";
$this->view->selectmenu = "outbox";
$response = $this->smsweb->getCommands();
$data = str_getcsv($response, "\n");
$sendresponses = "";
print_r($response);
if (!empty($response)) {
foreach ($data as $jsonsms) {
$sms = json_decode($jsonsms);
$textpart = str_getcsv($sms->msg, "#");
$group = $textpart[0];
$msg = $textpart[1];
$userslist = Users::find(array(array('group' => $group)));
$num = str_replace("+62", "0", $sms->from);
$cekuserongroup = Users::find(array(array('group' => $group, 'num' => $num)));
if ($userslist && $cekuserongroup) {
//if group exist
$rcpt = "";
foreach ($userslist as $user) {
if (!$rcpt) {
$rcpt = $user->num;
} else {
$rcpt = $rcpt . ',' . $user->num;
}
}
$sendresponse = $this->smsweb->sendSMS($rcpt, $msg);
}
$sendresponses = $sendresponses . "\n" . $sendresponse;
}
}
$this->view->response = $sendresponses;
}
示例10: getUsersList
private function getUsersList()
{
$model = Users::find()->where(['status' => 1])->all();
foreach ($model as $data) {
$user[$data->id] = ['id' => $data->id, 'username' => $data->login, 'password' => $data->password, 'authKey' => 'test' . $data->id . 'key', 'accessToken' => $data->id . '-token'];
}
return $user;
}
示例11: finduser
public function finduser()
{
$this->model('Users');
$user = new Users();
$user->id = 1;
$user->find();
echo $user->FirstName . ' ' . $user->LastName;
}
示例12: findByUsername
/**
* Finds user by username
*
* @param string $username
* @return static|null
*/
public static function findByUsername($username)
{
$dbuser = Users::find()->where(["username" => $username])->one();
if (!count($dbuser)) {
return null;
}
return new static($dbuser);
}
示例13: testAction
/**
* @param array $params
*/
public function testAction()
{
$users = Users::find();
if ($users) {
foreach ($users as $user) {
echo $user->name . '-' . $user->email . PHP_EOL;
}
}
}
示例14: listAction
public function listAction()
{
$this->view->users = Users::find();
//ECHO '<pre>';
//print_r(get_class_methods($users));
//print_r($users->toArray());
//echo '</pre>';
echo $this->view->render("users/list");
}
示例15: getById
public static function getById($id)
{
foreach (Users::find() as $u) {
if ($u->id == $id) {
return $u;
}
}
return false;
}