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

class Keywords_model extends MY_Model {

    public $table = 'keywords';


    public function __construct()
    {
        parent::__construct();
    }
    
    public function insert($data){
        return $this->db->insert($this->table, $data);
    }

    public function get_keywords($where,$field,$limit, $offset){
       $data=array();
       $this->db->select($field);
        if(count($where)>0)
        {
            $where = implode(' and ', $where);
            $this->db->where($where);
        }
       $this->db->order_by('createtime', 'DESC');
       $this->db->order_by('id', 'DESC');
       return $this->db->get($this->table, $limit, $offset)->result_array();
    }

    public function get_count($where)
    {
        if(count($where)>0)
        {
            $where = implode(' and ', $where);
            $this->db->where($where);
        }
        
        return $this->db->count_all_results($this->table);
    }

    public function bantch_delete($ids)
    {
        $tids = explode(',', $ids);
        foreach($tids as $id) {
            $this->db->where('id', $id);
            $this->db->update($this->table, array('isdelete' => 1));
        }
    }


   

}