本文整理汇总了PHP中Model::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::where方法的具体用法?PHP Model::where怎么用?PHP Model::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model
的用法示例。
在下文中一共展示了Model::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkLogin
public function checkLogin()
{
//用户登陆检测,若成功,把登陆时间与IP插入数据库
$verify = $this->_param('verify');
//$_POST['verify'];
if ($_SESSION['verify'] != md5($verify)) {
$this->error('验证码错误!');
}
$admin_name = $this->_param('admin_name');
$admin_pw = $this->_param('admin_pw');
$m = new Model('admin');
//查看管理员表中有没有该用户信息 注:管理员与普通用户为2个表!!!
$where = 'user_name="' . $admin_name . '" AND password="' . md5($admin_pw) . '" AND state=0';
$res = $m->where($where)->find();
if (count($res) > 0) {
//判断是否有管理员信息
$data['last_login_ip'] = get_client_ip();
$data['last_login_time'] = time();
$where = 'id=' . $res['id'];
$m->where($where)->save($data);
session_start();
$_SESSION['username'] = $res['user_name'];
$_SESSION['islogin'] = 1;
//$_SESSION['level']=2;
$this->redirect('Index/main');
} else {
$this->error('密码错误或账号不存在或者已经被禁用!', U('Escape/login'));
}
}
示例2: _list
/**
+----------------------------------------------------------
* 根据表单生成查询条件
* 进行列表过滤
+----------------------------------------------------------
* @access protected
+----------------------------------------------------------
* @param Model $model 数据对象
* @param HashMap $map 过滤条件
* @param string $sortBy 排序
* @param boolean $asc 是否正序
+----------------------------------------------------------
* @return void
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
protected function _list($model, $map, $sortBy = '', $asc = false)
{
//排序字段 默认为主键名
if (isset($_REQUEST['_order'])) {
$order = $_REQUEST['_order'];
} else {
$order = !empty($sortBy) ? $sortBy : $model->getPk();
}
//取得满足条件的记录数
$count = $model->where($map)->count('id');
if ($count > 0) {
import("ORG.Util.Page");
//创建分页对象
if (!empty($_REQUEST['listRows'])) {
$listRows = $_REQUEST['listRows'];
} else {
$listRows = '';
}
$p = new Page($count, $listRows);
//分页查询数据
$voList = $model->where($map)->order("" . $order . " desc")->limit($p->firstRow . ',' . $p->listRows)->select();
//分页跳转的时候保证查询条件
foreach ($map as $key => $val) {
if (!is_array($val)) {
$p->parameter .= "{$key}=" . urlencode($val) . "&";
}
}
//分页显示
$page = $p->show();
//列表排序显示
$sortImg = $sort;
//排序图标
$sortAlt = $sort == 'desc' ? '升序排列' : '倒序排列';
//排序提示
//模板赋值显示
$this->assign('list', $voList);
$this->assign('order', $order);
$this->assign('sortImg', $sortImg);
$this->assign('sortType', $sortAlt);
$this->assign("page", $page);
}
$MagazineType = M("MagazineType");
$MagazineTypeList = $MagazineType->field('id, name')->select();
$this->assign('MagazineTypeList', $MagazineTypeList);
$this->assign('totalCount', $count);
$this->assign('numPerPage', C('PAGE_LISTROWS'));
$this->assign('currentPage', !empty($_REQUEST[C('VAR_PAGE')]) ? $_REQUEST[C('VAR_PAGE')] : 1);
Cookie::set('_currentUrl_', __SELF__);
return;
}
示例3: getMsgList
function getMsgList($parm = array())
{
$M = new Model('member_msg');
$pre = C('DB_PREFIX');
$field = true;
$orderby = " id DESC";
if ($parm['pagesize']) {
//分页处理
import("ORG.Util.Page");
$count = $M->where($parm['map'])->count('id');
$p = new \Org\Util\Page($count, $parm['pagesize']);
$page = $p->show();
$Lsql = "{$p->firstRow},{$p->listRows}";
//分页处理
} else {
$page = "";
$Lsql = "{$parm['limit']}";
}
$data = M('member_msg')->field(true)->where($parm['map'])->order($orderby)->limit($Lsql)->select();
$symbol = C('MONEY_SYMBOL');
$suffix = C("URL_HTML_SUFFIX");
foreach ($data as $key => $v) {
}
$row = array();
$row['list'] = $data;
$row['page'] = $page;
$row['count'] = $count;
return $row;
}
示例4: index
public function index()
{
$Hot = new Model('Article');
$listHot = $Hot->where("blar_status=3")->order('blar_create_time desc')->limit(5)->select();
$this->assign('listHot', $listHot);
$Order = new Model('Article');
$listOrder = $Order->where("blar_status<>2")->order('blar_clicks desc, blar_create_time desc')->limit(10)->select();
$this->assign('listOrder', $listOrder);
$Article = new Model('Article');
// 实例化模型类
import("ORG.Util.Page");
$count = $Article->where("blar_status<>2")->count();
$Page = new Page($count, 5);
$show = $Page->show();
$list = $Article->where('blar_status<>2')->order('blar_create_time desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
// 查询数据
foreach ($list as $key => $art) {
$blar_id = $art["blar_id"];
$ViewArTags = new Model('view_ar_tags');
$result = $ViewArTags->where('blar_id=' . $blar_id)->select();
if (isset($result) && !empty($result)) {
$art["tags"] = $result;
}
$list[$key] = $art;
}
$this->assign('list', $list);
// 模板变量赋值
$this->assign('page', $show);
$this->display();
}
示例5: __construct
/**
* 构造函数
*
* @access public
* @param mixed $name
* @param mixed $password
* @return mixed
*/
public function __construct($name, $password)
{
$safebox = Safebox::getInstance();
$manager = $safebox->get('manager');
if (!isset($manager['id']) || $manager['id'] == '' || $manager['name'] != $name) {
$model = new Model('manager');
$name = Filter::sql($name);
$user = $model->where("name='" . $name . "'")->find();
if (!empty($user)) {
$key = md5($user['validcode']);
$password = substr($key, 0, 16) . $password . substr($key, 16, 16);
if ($user['password'] == md5($password)) {
$this->status = 'online';
$this->properties = $user;
$safebox->set('manager', $this->properties);
} else {
$this->status = 'offline';
$this->properties = null;
}
} else {
$this->status = 'offline';
$this->properties = null;
}
} else {
$this->status = 'online';
$this->properties = $safebox->get('manager');
}
}
示例6: item_desc
public function item_desc()
{
$where = 'type=3 AND status=1';
$obj = new Model('t_contents');
$res = $obj->where($where)->find();
$this->assign('res', $res);
$this->display();
}
示例7: proStatus
public function proStatus()
{
$project_hash = _get('get.token', null, '/^[a-z0-9]{30}$/');
if ($project_hash) {
$obj = new Model('project');
if ($obj->where("project_hash = '" . $project_hash . "'")->update(array('status' => '1'))) {
echo 'ok';
}
}
}
示例8: dtPerformGlobalFilter
/**
* Perform filter for global
*
* @param array $columns
* @param string $search
* @return self
*/
public function dtPerformGlobalFilter($columns, $search = '')
{
$this->dtModel = $this->dtModel->where(function ($query) use($columns, $search) {
foreach ($columns as $column) {
if (filter_var($column['searchable'], FILTER_VALIDATE_BOOLEAN) && !in_array($column['name'], $this->dtUnsearchable)) {
$query->orWhere(DB::raw($column['name']), 'LIKE', '%' . $search['value'] . '%');
}
}
});
return $this;
}
示例9: paymentVoucher
public static function paymentVoucher($voucherTemplate, $userID = null)
{
$model = new Model("voucher");
do {
$account = strtoupper(CHash::random(10, 'char'));
$password = strtoupper(CHash::random(10, 'char'));
$obj = $model->where("account = '{$account}'")->find();
} while ($obj);
$start_time = date('Y-m-d H:i:s');
$end_time = date('Y-m-d H:i:s', strtotime('+' . $voucherTemplate['valid_days'] . ' days'));
$model->data(array('account' => $account, 'password' => $password, 'name' => $voucherTemplate['name'], 'value' => $voucherTemplate['value'], 'start_time' => $start_time, 'end_time' => $end_time, 'money' => $voucherTemplate['money'], 'is_send' => 1, 'user_id' => $userID))->insert();
}
示例10: listall
function listall()
{
$projects = new Model('project');
@($res = $projects->field('project_name,project_desc,project_hash,time,status')->where("user_hash = '" . $_SESSION['user_hash'] . "'")->select());
//封装数组处理
$url = new Model('url');
foreach ($res as $key => &$value) {
$value['shellnum'] = $url->where("project_hash = '" . $value['project_hash'] . "'")->count();
$value['time'] = date('Y-m-d', $value['time']);
}
return $res;
}
示例11: group_insert
public function group_insert()
{
$data['name'] = $this->_post('name');
$data['mem_num'] = $this->_post('mem_num');
$data['resp'] = $this->_post('resp');
$data['phone'] = $this->_post('phone');
$vid = $this->get_volun_id();
$obj = new Model('t_group');
$res = $obj->where('resp=\'' . $vid . '\'')->find();
if (!empty($res)) {
//更新
$g_id = $this->_post('g_id');
$res2 = $obj->where('g_id=' . $g_id)->save($data);
} else {
$res2 = $obj->add($data);
}
if ($res2) {
$this->success('组织注册成功', '__APP__/Group/group', 3);
} else {
$this->error('组织注册失败', '', 3);
}
}
示例12: write
public static function write($user_id, $value, $note)
{
if (is_numeric($value)) {
$model = new Model('customer');
$customer = $model->where("user_id=" . $user_id)->find();
if ($customer) {
if ($value < 0) {
if ($customer['point'] < abs($value)) {
return array('status' => 'fail', 'msg' => '积分不够扣除!');
}
}
$new_point = $customer['point'] + $value;
$model->where("user_id=" . $user_id)->data(array('point' => $new_point))->update();
$logs = array('user_id' => $user_id, 'value' => $value, 'point' => $new_point, 'note' => $note, 'create_time' => date('Y-m-d H:i:s'));
$model = new Model('point_log');
$model->data($logs)->insert();
return true;
}
} else {
return array('status' => 'fail', 'msg' => '积分必需为数值。');
}
}
示例13: C
function ajax_arclist()
{
$prefix = !empty($_REQUEST['prefix']) ? (bool) $_REQUEST['prefix'] : true;
//表过滤防止泄露信息,只允许的表
if (!in_array($_REQUEST['model'], array('article', 'type', 'ad', 'label', 'link'))) {
exit;
}
if (!empty($_REQUEST['model'])) {
if ($prefix == true) {
$model = C('DB_PREFIX') . $_REQUEST['model'];
} else {
$model = $_REQUEST['model'];
}
} else {
$model = C('DB_PREFIX') . 'article';
}
$order = !empty($_REQUEST['order']) ? inject_check($_REQUEST['order']) : '';
$num = !empty($_REQUEST['num']) ? inject_check($_REQUEST['num']) : '';
$where = !empty($_REQUEST['where']) ? inject_check(urldecode($_REQUEST['where'])) : '';
//使where支持 条件判断,添加不等于的判断
$page = false;
if (!empty($_REQUEST['page'])) {
$page = (bool) $_REQUEST['page'];
}
$pagesize = !empty($_REQUEST['pagesize']) ? intval($_REQUEST['pagesize']) : '10';
//$query =!empty($_REQUEST['sql'])?$_REQUEST['sql']:'';//太危险不用
$field = '';
if (!empty($_REQUEST['field'])) {
$f_t = explode(',', inject_check($_REQUEST['field']));
$f_t = array_map('urlencode', $f_t);
$field = implode(',', $f_t);
}
$m = new Model($model, NULL);
//如果使用了分页,缓存也不生效
if ($page) {
import("ORG.Util.Page");
//这里改成你的Page类
$count = $m->where($where)->count();
$total_page = ceil($count / $pagesize);
$p = new Page($count, $pagesize);
//如果使用了分页,num将不起作用
$t = $m->field($field)->where($where)->limit($p->firstRow . ',' . $p->listRows)->order($order)->select();
//echo $m->getLastSql();
$ret = array('total_page' => $total_page, 'data' => $t);
}
//如果没有使用分页,并且没有 query
if (!$page) {
$ret = $m->field($field)->where($where)->order($order)->limit($num)->select();
}
$this->ajaxReturn($ret, '返回信息', 1);
}
示例14: __construct
/**
* 构造角色类,考虑到角色的修改,即时有效性,暂不考虑用Session保存
*
* @access public
* @param mixed $roles
* @return mixed
*/
public function __construct($roles = null)
{
if ($roles !== null) {
$key = $this->name . '_' . $roles;
$model = new Model('roles');
$result = $model->where("id=" . $roles)->find();
$this->roles = $result;
//Session::set($key,$this->roles);
/*else
{
$this->roles=Session::get($key);
}*/
}
}
示例15: mobansave
public function mobansave()
{
if (!IS_POST) {
$this->message2('无效请求!', __APP__ . '/Admin');
}
$site_template = I('site_template', 'default');
$data = array();
$data['site_template'] = $site_template;
$config_model = new Model('config');
if (false !== $config_model->where('id=1')->data($data)->save()) {
$this->message2('模板设置成功!', 'moban');
} else {
$this->message2('模板设置失败:' . $config_model->getError(), 'moban');
}
}