$table
$table :
我的收藏
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
/**
* 我的收藏
* */
class Usercollection_model extends CI_Model
{
private $table = 'usercollection';
public function __construct()
{
parent::__construct();
}
/**
* 添加
* */
public function insertData( $userData )
{
$bool = $this->db->insert($this->table, $userData);
$res = $bool ? $this->db->insert_id() : false;
return $res;
}
/**
* 统计论坛收藏的次数
* */
public function getCollectionCount( $listId=0,$typeFlag=0 )
{
$this->db->where('listId',$listId);
$this->db->where('typeFlag',$typeFlag);
return $this->db->count_all_results( $this->table );
}
/**
*获取单条数据
* */
public function getCollectionRow( $listId=0 ,$userId =0 ,$typeFlag=0)
{
$this->db->where('listId', $listId);
$this->db->where('userId', $userId);
$this->db->where('typeFlag',$typeFlag);
$result = $this->db->get($this->table);
return $result->row_array();
}
/**
* 获取收藏的数据
* */
public function getUserCollectionList( $typeFlag='' ,$userId=0 ,$limit=0 ,$start=0 )
{
$this->db->select('c.collectId,c.typeFlag,d.listId,d.title,d.brief,d.menuId,d.commentNum,d.tagIds,d.userId,d.isBetter,d.createTime,c.createTime as times');
$this->db->where('c.userId' ,$userId);
if(isset($typeFlag))
{
$this->db->where('c.typeFlag' ,$typeFlag);
}
$this->db->where('d.issue',1); //发布
$this->db->where('d.examinestatus',1);//通过审核
$this->db->where('d.status',0);//状态
$this->db->where('d.deleteFlag',0);//是否状态
$this->db->join('dzlist as d','d.listId=c.listId','right');
$this->db->order_by('createTime','desc')->limit($limit, $start);
return $this->db->get( $this->table .' as c')->result_array();
}
public function getUserCollectionCount( $typeFlag='' ,$userId=0 )
{
$this->db->where('c.userId' ,$userId);
if(isset($typeFlag))
{
$this->db->where('c.typeFlag' ,$typeFlag);
}
$this->db->where('d.issue',1); //发布
$this->db->where('d.examinestatus',1);//通过审核
$this->db->where('d.status',0);//状态
$this->db->where('d.deleteFlag',0);//是否状态
$this->db->join('dzlist as d','d.listId=c.listId','left');
return $this->db->count_all_results( $this->table .' as c');
}
/**
* 删除
* */
public function delete($collectId)
{
$this->db->where('collectId', $collectId);
return $this->db->delete($this->table);
}
/**
*获取单条数据
* */
public function getUserCollectionRow($collectionId=0)
{
$this->db->where('collectId', $collectionId);
$result = $this->db->get($this->table);
return $result->row_array();
}
}
?>