本文整理汇总了PHP中UserModel::select方法的典型用法代码示例。如果您正苦于以下问题:PHP UserModel::select方法的具体用法?PHP UserModel::select怎么用?PHP UserModel::select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserModel
的用法示例。
在下文中一共展示了UserModel::select方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUsersDataTable
public function getUsersDataTable()
{
$query = UserModel::select('username', 'roles', 'id')->get();
return Datatable::collection($query)->addColumn('id', function ($model) {
return '<a href="/users/' . $model->id . '">view</a>';
})->searchColumns('username', 'roles')->orderColumns('username', 'roles')->make();
}
示例2: index
public function index()
{
$usertype = Cookie::get('usertype');
if ($usertype === 'Manager') {
$user = new UserModel();
$teacher = new TeacherModel();
$course = new CourseModel();
$school = new SchoolModel();
$userlist = $user->select();
$teacherlist = $teacher->select();
$courselist = $course->select();
$schoollist = $school->select();
$username = Cookie::get('username');
$usertype = Cookie::get('usertype');
$lastlogintime = Cookie::get('lastlogintime');
$this->assign('userlist', $userlist);
$this->assign('teacherlist', $teacherlist);
$this->assign('courselist', $courselist);
$this->assign('schoollist', $schoollist);
$this->assign('username', $username);
$this->assign('usertype', $usertype);
$this->assign('lastlogintime', $lastlogintime);
$this->display();
} elseif ($usertype === 'teacher') {
$this->assign("jumpUrl", "__APP__/Teacher/login");
} else {
$this->assign("jumpUrl", "__APP__/Index/index");
$this->success("正在转向首页");
}
}
示例3: getUsersDataTable
/**
* @return bool
*/
public function getUsersDataTable()
{
$query = UserModel::select('username', 'roles', 'id')->get();
return Datatable::collection($query)->searchColumns('username', 'roles')->orderColumns('username', 'roles')->addColumn('username', function ($model) {
return $model->username;
})->addColumn('roles', function ($model) {
return $model->roles;
})->addColumn('Actions', function ($model) {
return "<a href='/projectinv/public/resource/" . $model->id . "' class='btn btn-success'>View</a>";
})->make();
}
示例4: index
public function index($args)
{
//var_dump(func_get_args());
print_r($args);
$user = new UserModel();
/*$user->insert('user', array(
'username' => 'chipolata',
'passwd' => 'shit happens',
'role' => 0
));*/
$user->select('uid');
var_dump($user->get(1));
}
示例5: define
<?php
/*
后台文件
Background entry file
*/
if (!defined('ACC')) {
define('ACC', true);
require '../system/init.php';
}
//
$user = new UserModel();
$userlist = $user->select();
$perPage = 7;
$curPage = isset($_GET['page']) ? $_GET['page'] : 1;
$pageObj = new PaginationHelper(count($userlist), $perPage, $curPage);
$pageMenu = $pageObj->showPageMenu();
$userlist = $user->selectLimited(($curPage - 1) * $perPage, $perPage);
$userlist = $user->dataByRealDate($userlist);
include __ROOT__ . 'view/admin/templates/userlist.html';
示例6: testDeleteAll
public function testDeleteAll()
{
$table = new UserModel();
$table->deleteAll();
$this->assertCount(0, $table->select());
}
示例7: editAction
/**
* 编辑
*
*/
public function editAction()
{
// 获取主键
$id = $this->getg('id', 0);
if (empty($id)) {
$this->error('id 不能为空!');
}
// 实例化Model
$user = new UserModel();
// 处理Post
if ($this->getRequest()->isPost()) {
// 获取所有post数据
$pdata = $this->getAllPost();
// 处理图片等特殊数据
// 验证
$result = $user->validation->validate($pdata, 'edit');
$user->parseAttributes($pdata);
// 通过验证
if ($result) {
// 入库前数据处理
// Model转换成数组
$data = $user->toArray($pdata);
$result = $user->update(array('id' => $id), $data);
if ($result) {
// 提示信息并跳转到列表
Tools_help::setSession('Message', '修改成功!');
$this->redirect('/backend/user/index');
} else {
// 出错
Tools_help::setSession('ErrorMessage', '修改失败, 请确定已修改了某项!');
$this->_view->assign("errors", $user->validation->getErrorSummary());
}
$user->id = $id;
} else {
// 验证失败
Tools_help::setSession('ErrorMessage', '修改失败, 请检查错误项');
$this->_view->assign("errors", $user->validation->getErrorSummary());
}
}
// 如果Model数据为空,则获取
if (!empty($id) && empty($user->id)) {
$data = $user->select(array('where' => array('id' => $id)));
$user->parseAttributes($data);
}
// 格式化表单数据
// 模版分配数据
$this->_view->assign("user", $user);
$this->_view->assign("pageTitle", '修改');
}
示例8: UserModel
<?php
/*验证用户名*/
define('ACC', true);
require './include/init.php';
$user = new UserModel();
$rs = $user->select();
//print_r($rs);
$u = $_REQUEST['username'];
foreach ($rs as $v) {
if ($v['username'] == $u) {
echo '用户名已存在';
//return false;
}
}
//echo '用户名已存在';
示例9: getUserDic
public function getUserDic()
{
return $this->userDao->select(['name', 'id']);
}