本文整理汇总了PHP中obj::where方法的典型用法代码示例。如果您正苦于以下问题:PHP obj::where方法的具体用法?PHP obj::where怎么用?PHP obj::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obj
的用法示例。
在下文中一共展示了obj::where方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _list
/**
* 列表处理
*
* @param obj $model 实例化后的模型
* @param array $map 条件数据
* @param string $sort_by 排序字段
* @param string $order_by 排序方法
* @param string $field_list 显示字段
* @param intval $pagesize 每页数据行数
*/
protected function _list($model, $map = array(), $sort_by = '', $order_by = '', $field_list = '*', $page, $pagesize = 10)
{
//排序
$mod_pk = $model->getPk();
if ($this->_request("sort", 'trim')) {
$sort = $this->_request("sort", 'trim');
} else {
if (!empty($sort_by)) {
$sort = $sort_by;
} else {
if ($this->sort) {
$sort = $this->sort;
} else {
$sort = $mod_pk;
}
}
}
if ($this->_request("order", 'trim')) {
$order = $this->_request("order", 'trim');
} else {
if (!empty($order_by)) {
$order = $order_by;
} else {
if ($this->order) {
$order = $this->order;
} else {
$order = 'ASC';
}
}
}
if ($page) {
$count = $model->where($map)->count($mod_pk);
$appjson['count'] = intval($count);
$pagecount = ceil($count / $pagesize);
$start = ($page - 1) * $pagesize;
$appjson['pagecount'] = $pagecount;
}
$select = $model->field($field_list)->where($map)->order($sort . ' ' . $order);
$this->list_relation && $select->relation(true);
if ($page) {
$select->limit($start . ',' . $pagesize);
}
$list = $select->select();
$appjson['list'] = $list;
return $appjson;
}
示例2: _list
/**
* 列表处理
*
* @param obj $model 实例化后的模型
* @param array $map 条件数据
* @param string $sort_by 排序字段
* @param string $order_by 排序方法
* @param string $field_list 显示字段
* @param intval $pagesize 每页数据行数
*/
protected function _list($model, $map = array(), $sort_by = '', $order_by = '', $field_list = '*', $pagesize = 50)
{
//排序
$mod_pk = $model->getPk();
if ($this->_request("sort", 'trim')) {
$sort = $this->_request("sort", 'trim');
} else {
if (!empty($sort_by)) {
$sort = $sort_by;
} else {
if ($this->sort) {
$sort = $this->sort;
} else {
$sort = $mod_pk;
}
}
}
if ($this->_request("order", 'trim')) {
$order = $this->_request("order", 'trim');
} else {
if (!empty($order_by)) {
$order = $order_by;
} else {
if ($this->order) {
$order = $this->order;
} else {
$order = 'DESC';
}
}
}
if ($pagesize) {
$count = $model->where($map)->count($mod_pk);
$pager = new Page($count, $pagesize);
}
$select = $model->field($field_list)->where($map)->order($sort . ' ' . $order);
$this->list_relation && $select->relation(true);
if ($pagesize) {
$select->limit($pager->firstRow . ',' . $pager->listRows);
$page = $pager->show();
$this->assign("page", $page);
}
$list = $select->select();
$this->assign('list', $list);
$this->assign('list_table', true);
}
示例3: _list
/**
* 列表处理
*
* @param obj $model 实例化后的模型
* @param array $map 条件数据
* @param string $sort_by 排序字段
* @param string $order_by 排序方法
* @param string $field_list 显示字段
* @param intval $pagesize 每页数据行数
*/
protected function _list($model, $map = array(), $sort_by = '', $order_by = '', $field_list = '*', $pagesize = 20)
{
//排序
$mod_pk = $model->getPk();
if (input("request.sort", 'trim')) {
$sort = input("request.sort", 'trim');
} else {
if (!empty($sort_by)) {
$sort = $sort_by;
} else {
if ($this->sort) {
$sort = $this->sort;
} else {
$sort = $mod_pk;
}
}
}
if (input("request.order", 'trim')) {
$order = input("request.order", 'trim');
} else {
if (!empty($order_by)) {
$order = $order_by;
} else {
if ($this->order) {
$order = $this->order;
} else {
$order = 'DESC';
}
}
}
//如果需要分页
if ($pagesize) {
$count = $model->where($map)->count($mod_pk);
$pager = new \Common\ORG\Page($count, $pagesize);
}
$select = $model->field($field_list)->where($map)->order($sort . ' ' . $order);
// echo M()->getLastSql();
$this->list_relation && $select->relation(true);
if ($pagesize) {
$select->limit($pager->firstRow . ',' . $pager->listRows);
$page = $pager->show();
$this->assign("page", $page);
}
$list = $select->select();
foreach ($list as $key => $value) {
$catename = M('user_category')->field('name')->where(array('id' => $value['uid']))->find();
$value['cname'] = $catename['name'];
$list[$key] = $value;
//重复值list
}
//dump($list);
$this->assign('list', $list);
$this->assign('list_table', true);
}
示例4: _list
/**
* 列表处理
*
* @param obj $model 实例化后的模型
* @param array $map 条件数据
* @param string $sort_by 排序字段
* @param string $order_by 排序方法
* @param string $field_list 显示字段
* @param intval $pagesize 每页数据行数
*/
protected function _list($model, $map = array(), $sort_by = '', $order_by = '', $field_list = '*', $pagesize = 20)
{
//排序
$mod_pk = $model->getPk();
if ($this->_request("sort", 'trim')) {
$sort = $this->_request("sort", 'trim');
} else {
if (!empty($sort_by)) {
$sort = $sort_by;
} else {
if ($this->sort) {
$sort = $this->sort;
} else {
$sort = $mod_pk;
}
}
}
if ($this->_request("order", 'trim')) {
$order = $this->_request("order", 'trim');
} else {
if (!empty($order_by)) {
$order = $order_by;
} else {
if ($this->order) {
$order = $this->order;
} else {
$order = 'DESC';
}
}
}
//如果需要分页
if ($pagesize) {
$count = $model->where($map)->count($mod_pk);
$pager = new Page($count, $pagesize);
}
$select = $model->field($field_list)->where($map)->order($sort . ' ' . $order);
$this->list_relation && $select->relation(true);
if ($pagesize) {
$select->limit($pager->firstRow . ',' . $pager->listRows);
$page = $pager->show();
$this->assign("page", $page);
}
$list = $select->select();
foreach ($list as &$item) {
switch ($item['color']) {
case '1':
$item['color'] = '黑';
break;
case '2':
$item['color'] = '红';
break;
case '3':
$item['color'] = '绿';
break;
case '4':
$item['color'] = '蓝';
break;
default:
$item['color'] = '黑';
break;
}
}
$this->assign('list', $list);
$this->assign('list_table', true);
}
示例5: _list
/**
* 列表处理
*
* @param obj $model 实例化后的模型
* @param array $map 条件数据
* @param string $sort_by 排序字段
* @param string $order_by 排序方法
* @param string $field_list 显示字段
* @param intval $pagesize 每页数据行数
*/
protected function _list($model, $map = array(), $sort_by = '', $order_by = '', $field_list = '*', $pagesize = 10)
{
//排序
$mod_pk = $model->getPk();
if (i("sort", '', 'trim')) {
$sort = i("sort", '', 'trim');
} else {
if (!empty($sort_by)) {
$sort = $sort_by;
} else {
if ($this->sort) {
$sort = $this->sort;
} else {
$sort = $mod_pk;
}
}
}
if (i("order", '', 'trim')) {
$order = i("order", '', 'trim');
} else {
if (!empty($order_by)) {
$order = $order_by;
} else {
if ($this->order) {
$order = $this->order;
} else {
$order = 'DESC';
}
}
}
/**
* 如果有where 存在,并且形式是数组,则合并条件
*/
if ($this->where && is_array($this->where)) {
//dump($this->where);
$map = array_merge($this->where, $map);
}
// dump(property_exists(CONTROLLER_NAME."Action","where"));
/**
* 如果设定全局翻页变量,则覆盖原来的默认值。
*/
$pagesize = property_exists($this, "pagesize") ? $this->pagesize : $pagesize;
// dump(property_exists($this,"pagesize"));
//如果需要分页
if ($pagesize) {
$count = $model->where($map)->count($mod_pk);
import('Page', APP_PATH . '/Lib');
$pager = new \Page($count, $pagesize);
}
$select = $model->field($field_list)->where($map)->order($sort . ' ' . $order);
$this->list_relation && $select->relation(true);
if ($pagesize) {
$select->limit($pager->firstRow . ',' . $pager->listRows);
$page = $pager->show();
$this->assign("page", $page);
}
$list = $select->select();
// dump($select->getLastSql());//exit();
// print_r($list);exit();
/**
* 如果需要处理数据则处理数据以后再返回
*/
if (method_exists($this, '_before_list')) {
$list = $this->_before_list($list);
}
$p = i('get.p', 1, 'intval');
$this->assign('p', $p);
$this->assign('list', $list);
$this->assign('list_table', true);
return $list;
}