<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Topic_post_model extends MY_Model {

    public $table = 'topic_post';
    protected $insert_filed = array('tid','pid','createtime');

    public function __construct()
    {
        parent::__construct();
    }

    public function insert($data)
    {
        return parent::insert($data);
    }

    public function get_by_tid($tid, $limit, $page = 0, $field = 'pid') {
        $this->db->select($field);
        $this->db->where('tid', $tid);
        $this->db->order_by('createtime', 'DESC');
        $offset = $page * $limit;
        return $this->db->get($this->table, $limit, $offset)->result_array();
    }

    public function get_tids_by_pid($pid) {
        $this->db->where('pid', $pid);
        $this->db->order_by('createtime', 'DESC');
        return $this->db->get($this->table)->result_array();
    }

    public function get_tids_by_pids($pids=array()) {
        $this->db->where_in('pid', $pids);
        $this->db->order_by('createtime', 'DESC');
        return $this->db->get($this->table)->result_array();
    }



}