本文整理汇总了PHP中Users::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::select方法的具体用法?PHP Users::select怎么用?PHP Users::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Users
的用法示例。
在下文中一共展示了Users::select方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modelAction
public function modelAction($offset = 0)
{
$this->_view->title = 'Model Database MVC';
$users = new Users();
$users->select('count(user_id) As Total');
$row = $users->query()->fetch();
$items_per_page = 15;
$offset = $offset % $items_per_page != 0 ? 0 : $offset;
$users->select();
$users->orderBy('user_id', 'DESC');
$users->limit($offset, $items_per_page);
$rs = $users->query();
$pages = new Paginator();
$pages->current_url = base_url() . 'database/model/model/%d';
$pages->offset = $offset;
$pages->items_per_page = $items_per_page;
$pages->items_total = $row['Total'];
$pages->mid_range = 7;
$pages->paginate();
$this->_view->pages = $pages;
$this->_view->rs = $rs;
$this->_view->add_link = base_url() . 'database/model/add-model/';
$this->_view->edit_link = base_url() . 'database/model/edit-model/';
$this->_view->delete_link = base_url() . 'database/model/delete-model/';
$this->renderView('database/model/index');
}
示例2: create_user
public function create_user()
{
// If there are no users then let's create one.
$db = Database::get_instance();
$db->query('SELECT * FROM `users` LIMIT 1');
if ($db->has_rows() && !Auth::get_instance()->logged_in()) {
Flash::set('<p class="flash validation">Sorry but to create new users, you must be logged in.</p>');
Core_Helpers::redirect(WEB_ROOT . 'login/');
}
$validator = Error::instance();
if (isset($_POST['email'])) {
$validator->email($_POST['email'], 'email');
$validator->blank($_POST['username'], 'username');
$validator->blank($_POST['password'], 'password');
$validator->passwords($_POST['password'], $_POST['confirm_password'], 'confirm_password');
$user = new Users();
if ($user->select(array('username' => $_POST['username']))) {
$validator->add('username', 'The username <strong>' . htmlspecialchars($_POST['username']) . '</strong> is already taken.');
}
if ($validator->ok()) {
$user = new Users();
$user->load($_POST);
$user->level = 'admin';
$user->insert();
Flash::set('<p class="flash success">User created successfully.</p>');
Core_Helpers::redirect(WEB_ROOT . 'login/');
}
}
$this->data['error'] = $validator;
$this->load_template('create_user');
}
示例3: indexAction
function indexAction()
{
$this->metas(array('DC.Title' => 'Administration'));
$this->actions->append("Paramètres du site", array('action' => 'parametres'));
$this->view->indicateurs = $m = new Wtk_Table_Model('label', 'url', 'compteur', 'level');
$config = Zend_Registry::get('config');
$m->append('Version', null, Strass_Version::PROJET, array('version-produit', 'notice'));
$m->append('Version des données', null, Strass_Version::dataCurrent(), array('version-data', strass_admin_count_level(Strass_Version::DATA - Strass_Version::dataCurrent(), 1, 1)));
$m->append('Association', null, strtoupper($config->system->association), 'notice');
$t = new Inscriptions();
$count = $t->countRows();
$m->append("Inscriptions à valider", $this->_helper->Url('valider', 'membres'), $count, strass_admin_count_level($count, 1, 5));
$t = new Unites();
$count = $t->countRows();
$m->append("Unités", $this->_helper->Url('unites'), $count, strass_admin_count_level(0 - $count, 0, 0));
$t = new Individus();
$count = $t->countRows();
$m->append("Fiches d'individu", $this->_helper->Url('index', 'individus'), $count, 'notice');
$t = new Users();
$count = $t->countRows();
$m->append("Membres", $this->_helper->Url('index', 'individus', null, array('filtre' => 'membres')), $count, 'notice');
$t = new Citation();
$count = $t->countRows();
$m->append("Citations", $this->_helper->Url('index', 'citation'), $count, 'notice');
$this->view->log = $m = new Wtk_Table_Model('date', 'level', 'logger', 'label', 'url', 'prenom-nom', 'fiche', 'detail-url');
$t = new Logs();
$events = $t->fetchAll($t->select()->order('date DESC')->limit(20));
foreach ($events as $e) {
$url = $this->_helper->Url('event', null, null, array('id' => $e->id));
$u = $e->findParentUsers();
if ($u) {
$i = $u->findParentIndividus();
$pn = $i->getFullname();
$fiche = $this->_helper->Url('fiche', 'individus', null, array('individu' => $i->slug));
} else {
$pn = 'Visiteur';
$fiche = null;
}
$m->append($e->date, strtolower($e->level), $e->logger, $e->message, $e->url, $pn, $fiche, $url);
}
$this->view->connexions = $m = new Wtk_Table_Model('date', 'prenom-nom', 'fiche');
$t = new Users();
$users = $t->fetchAll($t->select()->where('last_login')->order('last_login DESC')->limit(8));
foreach ($users as $u) {
$i = $u->findParentIndividus();
$m->append($u->last_login, $i->getFullname(false, false), $this->_helper->Url('fiche', 'individus', null, array('individu' => $i->slug)));
}
}
示例4: Users
<?php
/**
* Created by PhpStorm.
* User: just
* Date: 16.03.16
* Time: 07:11
*/
require_once 'autoload.php';
$user = new Users();
//var_dump(isset($_POST['login']));
if (!empty($_POST['login'])) {
$_POST['table'] = 'users';
$_POST['where'] = 'username';
$_POST['has'] = $_POST['username'];
$result = $user->select($_POST, 1);
// var_dump($result);
// die;
//
if (!$result) {
echo 'Няма открит потребител';
} else {
if ($result->user_pass !== md5($_POST['pass'])) {
echo 'Грешна парола';
} else {
// $_SESSION['user'] = $result;
foreach ($result as $k => $v) {
if ($k !== 'user_pass') {
$_SESSION[$k] = $v;
}
if ($k === 'user_about') {
示例5: __construct
<?php
class Users extends Table
{
}
require_once 'Mysql.class.php';
$db = new Mysql('localhost', 'root', 'root', 'test');
Table::setDefaultAdapter($db);
$users = new Users();
print_r($users->select()->where('id%2=0')->limit(5)->fetchAll());
abstract class Table
{
protected $_table;
protected static $_db;
public function __construct()
{
$this->_table = get_class($this);
$this->_init();
}
public static function setDefaultAdapter($db)
{
self::$_db = $db;
}
protected function _init()
{
}
function insert($bind)
{
return self::$_db->insert($this->_table, $bind);
}
function update($bind, $where = NULL)
示例6: if
<?php
require_once 'tables.php';
// header('Content-Type: text/event-stream');
// header('Cache-Control: no-cache');
/*
code=0 ----------> pagination
code=1 ----------> delete
code=2 ----------> edit
*/
$user = new Users();
$totalRes = $user->select();
if ($_GET['code'] == "1") {
$user->uid = $_GET['UID'];
// echo "hiiiiiii" ;
// echo $_GET['UID'] ;
$user->delete();
}
/*
else if ($_GET['code'] == "2"){};*/
$limit = isset($_GET['limit']) ? $_GET['limit'] : 0;
$res = $user->selectLimit($limit, 4);
$usersArray = array();
for ($i = 0; $i < count($res); $i++) {
$usersArray[$i]['name'] = $res[$i][1];
$usersArray[$i]['room'] = $res[$i][6];
$usersArray[$i]['image'] = $res[$i][4];
$usersArray[$i]['ext'] = $res[$i][5];
}
$replayArr["allRowsNum"] = count($totalRes);
$replayArr["usersArray"] = $usersArray;
示例7: executeSearch
public function executeSearch()
{
// $this->validAjaxRequest();
$ajax = new \AjaxResponse();
$query = \Users::select();
$keyword = $this->get('keyword');
$section = $this->get('section');
$status = $this->get('status');
$banned = $this->get('banned', 'INT', -1);
$ordering = $this->get('ordering', 'STRING', 'username');
//paging
$page = $this->get('page', 'INT', 1);
//search by keyword
if ($keyword) {
if (is_numeric($keyword)) {
$query->andWhere('`id` = :keyword');
$query->setParameter(':keyword', $keyword, \PDO::PARAM_INT);
} else {
if (Util::isValidEmail($keyword)) {
$query->andWhere('`email` = :keyword');
$query->setParameter(':keyword', $keyword, \PDO::PARAM_STR);
} else {
$keyword = explode(' ', $keyword);
foreach ($keyword as $k) {
$k = trim($k);
if ($k) {
$query->orWhere('`username` LIKE "%' . $k . '%"')->orWhere('`name` LIKE "%' . $k . '%"');
}
}
}
}
}
//search by section
if ($section) {
$query->andWhere("`section` = :section")->setParameter(':section', $section, \PDO::PARAM_STR);
}
//search by status
if ($status) {
$query->andWhere('`status` = :status')->setParameter(':status', $status, \PDO::PARAM_STR);
}
//search by is banned
if (-1 != $banned) {
$query->andWhere('`banned` = :banned')->setParameter(':banned', $banned, \PDO::PARAM_INT);
}
switch ($ordering) {
case 'last_visit_time':
$query->orderBy('last_visit_time', 'DESC');
break;
case 'register_time':
$query->orderBy('register_time', 'DESC');
break;
default:
$query->orderBy('username', 'ASC');
}
//count for paging
$countQuery = clone $query;
$total = $countQuery->count('id')->execute();
$query->setMaxResults($this->maxRecordPerPage)->setFirstResult(($page - 1) * $this->maxRecordPerPage);
/** @var \Users[] $users */
$users = $query->execute();
$result = array();
if (!empty($users)) {
foreach ($users as $user) {
$t = $user->toArray();
unset($t['password']);
unset($t['secret']);
if (!$user->getBirthday()->isEmpty()) {
$t['birthday'] = $user->getBirthday()->format('d/m/Y');
} else {
$t['birthday'] = null;
}
$t['deleted'] = $user->isDeleted();
$t['avatar'] = \Toxotes\Util::gravatar($user->getEmail(), '32');
$t['edit_link'] = $this->createUrl('user/edit', ['id' => $user->getId()]);
$result[] = $t;
}
}
$ajax->type = \AjaxResponse::SUCCESS;
$ajax->users = $result;
$ajax->total = $total;
$ajax->page_size = $this->maxRecordPerPage;
$ajax->page = $page;
return $this->renderText($ajax->toString());
}
示例8: getRolesMembers
/**
* get roles's members by ids
* @param $roles_id
* @return \Users[]
*/
public static function getRolesMembers($roles_id)
{
$roles_id = (array) $roles_id;
$result = [];
if (!empty($roles_id)) {
$result = \Users::select()->where('`id` IN (SELECT user_id FROM `user_role` WHERE `role_id` IN (' . implode(',', $roles_id) . '))')->execute();
}
return $result;
}
示例9: Orders
<?php
require 'tables.php';
if (isset($_GET['oid'])) {
$orders = new Orders();
$orders->oid = $_GET['oid'];
$orders->status = 'canceled';
$orders->updateStatus();
} else {
//selectbykey
$users = new Users();
if (isset($_GET['uid']) && $_GET['uid'] != 'all') {
$usersData->uid = $_GET['uid'];
$usersData = $users->selectbykey();
} else {
$usersData = $users->select();
}
//echo $usersData;
$allusersData = array();
for ($u = 0; $u < count($usersData); $u++) {
$orders = new Orders();
$orders->uid = $usersData[$u][0];
if (isset($_GET['from']) && isset($_GET['to'])) {
$data = $orders->selectbydate($_GET['from'], $_GET['to']);
} else {
//all orders for define user
$data = $orders->selectbyId();
}
$allusersData[$u]['uid'] = $usersData[$u][0];
$allusersData[$u]['name'] = $usersData[$u][1];
$response = array();
示例10: browseAction
public function browseAction()
{
$form = new Modules_Admin_Controllers_Users_Browse_Form();
$cache = Zend_Registry::get('cache');
$roles = $cache->load(md5(UNIQUE_HASH . 'roles'));
if ($roles === false) {
$rolesTable = new Roles();
$roles = $rolesTable->fetchAll();
$cache->save($roles, md5(UNIQUE_HASH . 'roles'));
}
foreach ($roles as $role) {
if ($role->id != 1) {
$form->getElement('role')->addMultiOption($role->id, $role->name);
}
}
$router = $this->getFrontController()->getRouter();
if ($page = (int) $this->getRequest()->getParam('page')) {
$router->setGlobalParam('page', $page);
}
if ($belongs = (int) $this->getRequest()->getParam('belongs')) {
$router->setGlobalParam('belongs', $belongs);
}
if ($role = $this->getRequest()->getParam('role')) {
$router->setGlobalParam('role', $role);
}
if ($order = $this->getRequest()->getParam('order')) {
$router->setGlobalParam('order', $order);
}
if ($sort = $this->getRequest()->getParam('sort')) {
$router->setGlobalParam('sort', $sort);
}
$form->getElement('role')->setValue($role);
$form->getElement('belongs')->setValue($belongs);
$this->view->form = $form;
$usersTable = new Users();
#fetching the data from table
$select = $usersTable->select()->from(array('u' => 'users'));
$select->setIntegrityCheck(false);
$select->where('u.id > ?', 1);
if ($role) {
if ($belongs) {
$select->join(array('ur' => 'users_roles'), 'ur.user=u.id AND ur.role=' . (int) $role);
} else {
$select->joinLeft(array('ur' => 'users_roles'), 'ur.user=u.id AND ur.role=' . (int) $role);
$select->where('ur.role is null');
}
}
switch ($sort) {
case 'desc':
$sort = 'DESC';
break;
default:
$sort = 'ASC';
}
switch ($order) {
case 'username':
$select->order('u.email ' . $sort);
break;
case 'email':
$select->order('u.email ' . $sort);
break;
case 'dateOfRegistration':
$select->order('u.registered_timestamp ' . $sort);
break;
}
$this->view->usersPaginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($select));
$this->view->usersPaginator->setItemCountPerPage(50);
$this->view->usersPaginator->setCurrentPageNumber($page);
}
示例11: changeAvatar
/**
*
* @param unknown_type $userId
* @param unknown_type $newAvatar
*/
public static function changeAvatar($userId, $newAvatar = 0)
{
// save information into people table (users)
$people = new Users();
$rowPeople = $people->fetchRow("id = " . $userId);
if (isset($rowPeople)) {
// store old avatar
$oldAvatar = $rowPeople->avatar;
// update avatar
$dataUsers = array('avatar' => $newAvatar);
if (!$people->update($dataUsers, "id = " . $userId)) {
return false;
}
// link avatar to system folder
if ($newAvatar > 0) {
self::linkAvatarToSystemFolder($newAvatar);
}
// if old avatar, check if another user has the same avatar
if ($oldAvatar > 0) {
// search avatar
$select = $people->select()->where('avatar = ?', $oldAvatar);
$rowsetPeople = $people->fetchAll($select);
// if no avatar found, clean link between avatar and folder
if (count($rowsetPeople) == 0) {
$objectFolder = new Filfolders();
// get id of filfolders "adminpeople" and isSystemFolder "1"
$rowFolder = $objectFolder->getFoldersByModule('adminpeople');
$objectLinkFolder = new FilfoldersFilfiles();
$objectLinkFolder->delete('filfiles_id = ' . $oldAvatar . ' AND filfolders_id = ' . $rowFolder->id);
}
}
return true;
}
}
示例12: Users
function verify_api_token($token)
{
$user = new Users();
return $user->select(array('api_token' => $token));
}