12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- class Admin_model extends MY_Model
- {
- /**
- * 操作表名
- * @access private
- * @author leefouce
- */
- private $table_name = 'admin';
- public function __construct() {
- parent::__construct();
- }
- public function insert($parm) {
- $this->db->insert($this->table_name, $parm);
- return $this->db->insert_id();
- }
- public function update($id, $parm) {
- $this->db->where('id', $id);
- $this->db->update($this->table_name, $parm);
- return $this->db->affected_rows();
- }
- /**
- * 删除功能,set adStatus = 1
- */
- public function delete($id) {
- $this->db->where('id', $id);
- $parm['adStatus'] = 1;
- $this->db->update($this->table_name, $parm);
- return $this->db->affected_rows();
- }
- public function getDetailById($id){
- $this->db->select('*');
- $this->db->from($this->table_name);
- $this->db->where('id', $id);
- $this->db->where('adStatus', '0');
- $query = $this->db->get();
- return $query->num_rows() > 0 ? $query->result_array() : false;
- }
- public function getDetailByLogin($adLogin){
- $this->db->select('*');
- $this->db->from($this->table_name);
- $this->db->where('adLogin', $adLogin);
- $this->db->where('adStatus', '0');
- $query = $this->db->get();
- return $query->num_rows() > 0 ? $query->result_array() : false;
- }
- public function login($adLogin,$adPass){
- $this->db->select('*');
- $this->db->from($this->table_name);
- $this->db->where('adLogin', $adLogin);
- $this->db->where('adPass', $adPass);
- $this->db->where('adStatus', '0');
- $query = $this->db->get();
- return $query->num_rows() > 0 ? $query->result_array() : false;
- }
- public function isExistByAdLogin($adLogin){
- $this->db->from($this->table_name);
- $this->db->where('adLogin', $adLogin);
- $query = $this->db->get();
- return $query->num_rows() > 0 ? true : false;
- }
- public function getCount(){
- $this->db->select('count(id) as count');
- $this->db->where('adStatus', '0');
- $query = $this->db->get($this->table_name);
- $ret = $query->row_array();
- return $ret['count'];
- }
- public function getAll($offset,$rows){
- $this->db->where('adStatus','0');
- $this->db->limit($rows, $offset);
- $query = $this->db->get($this->table_name);
- return $query->num_rows() > 0 ? $query->result_array() : false;
- }
-
-
- }
|