public function run() { $model = new User(); //审核状态 $user_status = array('all' => '所有', User::STATUS_AUDIT => '待审核', User::STATUS_DISABLE => '禁用', User::STATUS_NORMAL => '正常'); //条件 $criteria = new CDbCriteria(); $groupid = intval(Yii::app()->request->getParam('groupid')); $username = trim(Yii::app()->request->getParam('username')); $status = Yii::app()->request->getParam('status', 'all'); $groupid > 0 && $criteria->addColumnCondition(array('groupid' => $groupid)); if ($status != 'all') { $criteria->addSearchCondition('status', $status); } $criteria->addSearchCondition('username', $username); $criteria->order = 'uid ASC'; $count = $model->count($criteria); //分页 $pages = new CPagination($count); $pages->pageSize = 10; $pages->applyLimit($criteria); //查询 $result = $model->findAll($criteria); $this->controller->render('index', array('datalist' => $result, 'pagebar' => $pages, 'status' => $status, 'user_status' => $user_status)); }
/** * Create response for fio autocomplite */ public function actionSearch() { $term = $_REQUEST['term']; $users = User::findAll($term); $result = array(); foreach ($users as $user) { $result[] = array('label' => $user['fio'], 'value' => $user['id']); } $this->showResponse($result); }
public static function index() { self::check_logged_in(); $user = self::get_user_logged_in(); if ($user->admin) { $users = User::findAll(); View::make('user/index.html', array('users' => $users)); } else { Redirect::to('/user/' . $user->id, array('warning' => 'Pääsy kielletty ilman ylläpito-oikeutta!')); } }
function actionExecute() { $user = new User(); $username = "******"; // 准备SQL,要删除username是“whoami”的家伙 $sql = "DELETE FROM test_user WHERE username = :username"; // 同query,execute第一个参数是SQL语句,第二个参数是绑定参数的列表 $this->result = $user->execute($sql, array(":username" => $username)); // execute返回参数和create等相同,即是影响行数,为0则证明没有做任何的修改 $this->findall = $user->findAll(); $this->display("db/execute.html"); }
public function index() { if (!AuthUser::hasPermission('user_view')) { Flash::set('error', __('You do not have permission to access the requested page!')); if (Setting::get('default_tab') === 'user') { redirect(get_url('page')); } else { redirect(get_url()); } } $this->display('user/index', array('users' => User::findAll())); }
/** * Render */ public function render() { $users = new User(); $users->order('Рейтинг', 'desc'); $users->limit($this->options->limit); if ($result = $users->findAll()) { $tpl = new Template('User/templates/widgets/top'); $tpl->users = $result; $this->code = $tpl->render(); } return parent::render(); }
/** * 首页 * */ public function actionIndex() { parent::_acl(); $model = new User(); $criteria = new CDbCriteria(); $criteria->order = 'id DESC'; $count = $model->count($criteria); $pages = new CPagination($count); $pages->pageSize = 10; $criteria->limit = $pages->pageSize; $criteria->offset = $pages->currentPage * $pages->pageSize; $result = $model->findAll($criteria); $this->render('index', array('datalist' => $result, 'pagebar' => $pages)); }
/** * * 管理员列表 */ public function actionAdmin() { $model = new User(); $criteria = new CDbCriteria(); $username = trim($this->_request->getParam('username')); $username && ($condition .= ' AND username LIKE \'%' . $username . '%\''); $criteria->condition = "status=1 AND groupid=" . $this->_adminGroupID . $condition; $criteria->order = 'id DESC'; $count = $model->count($criteria); $pages = new CPagination($count); $pages->pageSize = 13; $criteria->limit = $pages->pageSize; $criteria->offset = $pages->currentPage * $pages->pageSize; $result = $model->findAll($criteria); $this->render('user_index', array('adminPage' => 1, 'datalist' => $result, 'pagebar' => $pages)); }
function sendMassMessage($message, $group = 3) { if (empty($message)) { return false; } App::import('Model', 'User'); $User = new User(); $targets = $User->findAll("group_id > {$group}"); if (!empty($targets)) { $message['added'] = date('Y-m-d H:i:s'); $message['unread'] = 'yes'; foreach ($targets as $target) { $message['poster'] = $target['User']['id']; $this->sendMessage($message, false); } } }
/** * Users list */ public function listAction() { $this->_addHeadTitle("User list"); $this->view->users = User::findAll(); }
/** * Vrati zoznam vsetkych pouzivatel v systeme * * @param string $username * @return array of string array(array('userid'=>'username'), ...) */ public function users() { $User = new User(); // unbind all models $User->recursive = -1; // najdem vsetkych uzivatelov [toto moze byt dost dlhy zoznam!] $users = $User->findAll(null, array('id', 'username'), array('User.username ASC')); // prevediem na pozadovany vystupny tvar $output = array(); foreach ($users as $u) { $output[$u['User']['id']] = $u['User']['username']; } return $output; }
public function __construct() { $this->setLayout('backend'); $this->assignToLayout('sidebar', new View('../../plugins/skeleton/views/sidebar')); $this->userfindAll = User::findAll(); }
public function indexAction() { $result = User::findAll(); }
public function actionUserall() { $use = new User(); $data['user'] = $use->findAll(); $this->render("//backend/user/userall", $data); }
<?php require_once __DIR__ . '/autoload.php'; try { $data = User::findAll(); $n = new User(); $n->DeleteById(62); $n->Update('5555', '63'); //$data = User::findOne(); //Подстановка //$sth= $dbh->prepare('SELECT * FROM new_news WHERE id=:id'); //$sth->execute([':id' => 2]); //$sth= $dbh->prepare('SELECT count(*) FROM new_news '); //$sth->execute(); //$res = $sth->fetchOne(); //$res = $sth->fetchAll(PDO::FETCH_OBJ); //var_dump($res['0']['title']); //$res = $sth->fetchALL(PDO::FETCH_CLASS, User::class); //var_dump($data); } catch (PDOException $e) { echo $e->getMessage(); } echo $data['0']->avtor;
try { $user->populate(); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e - getMessage()); } } include VIEW_PATH . '/add_edit_user_settings.php'; } elseif ('delete' == $action) { try { $user = new User($user_id); if (fRequest::isPost()) { fRequest::validateCSRFToken(fRequest::get('token')); $user->delete(); fMessaging::create('success', User::makeUrl('edit', $user), 'The user ' . $user->getName() . ' was successfully deleted'); fURL::redirect(User::makeUrl('edit', $user)); } } catch (fNotFoundException $e) { fMessaging::create('error', User::makeUrl('edit', $user), 'The line requested could not be found'); fURL::redirect(User::makeUrl('edit', $user)); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/delete.php'; } else { if (!fAuthorization::checkAuthLevel('admin')) { fURL::redirect(User::makeURL('edit', fSession::get('user_id'))); } else { $users = User::findAll(); include VIEW_PATH . '/list_users.php'; } }
include_once 'partials/edit.php'; ?> <?php echo $messageDelete; ?> <table class="table table-hover"> <thead> <tr> <th>#</th> <th>Nome:</th> <th>E-mail:</th> <th>Ações:</th> </tr> </thead> <?php foreach ($user->findAll() as $key => $value) { ?> <tbody> <tr> <td><?php echo $value->id; ?> </td> <td><?php echo $value->name; ?> </td> <td><?php echo $value->email; ?> </td>
/** * Autocompleter */ public function autocomplete_action() { if ($query = $this->input->get('query')) { $user = new User(); $this->db->like('login', $query); if ($users = $user->findAll()) { $data = array('query' => $query, 'suggestions' => array()); foreach ($users as $user) { array_push($data['suggestions'], $user->login); } die(json_encode($data)); } } }
<?php require_once "models/User.php"; require_once "models/DB.php"; require_once "models/Post.php"; session_start(); if (!isset($_SESSION["user"])) { $user = new User(); $user->username = "******"; } else { $user = $_SESSION["user"]; } $posts = Post::sortByTime($dbh); $users = User::findAll($dbh); include_once "views/posts.php";