$table
$table :
Model Class
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Managepoints_model extends CI_Model
{
private $table = 'managepoints';
public function __construct()
{
parent::__construct();
}
/**
* 获取标签列表
* */
public function getManagePointsList($where=array(), $select = '*',$limit=10,$start=0)
{
$param = $this->_getWhere($where);
$this->db->select($select);
$this->db->where($param);
$this->db->order_by('pointsId','desc')->limit($limit, $start);
return $this->db->get( $this->table )->result_array();
}
/**
*获取单条数据
* */
public function getManagePointsRow($pointsId=0)
{
$this->db->where('pointsId', $pointsId);
$result = $this->db->get($this->table);
return $result->row_array();
}
/**
* 添加
* */
public function insertData($userData)
{
$res = $this->db->insert($this->table, $userData);
return $res;
}
/**
* 修改
* */
public function setManagePointsByID($updateData, $pointsId)
{
$this->db->where('pointsId', $pointsId);
return $this->db->update($this->table, $updateData);
}
/**
* 获取总条数
* */
public function getManagePointsCount($where=array())
{
$param = $this->_getWhere($where);
$this->db->where($param);
return $this->db->count_all_results( $this->table );
}
/**
* 查询条件
* */
public function _getWhere( $where=array() )
{
$param = array();
if (!empty($where['name']))
{
$param['name like'] = '%'.strval($where['name']).'%';
}
return $param;
}
/**
* 验证唯一
* */
public function checkUnique( $name ,$pointsId=0 )
{
$this->db->where('name', $name);
if(!empty($pointsId))
{
$this->db->where('pointsId !=', $pointsId);
}
$result = $this->db->get($this->table);
return $result->row_array();
}
/**
* 删除用户
* */
public function delete( $pointsId )
{
$this->db->where( 'pointsId', $pointsId );
$query = $this->db->delete( $this->table);
return $query ? $pointsId : false;
}
}
?>