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

class Praise_model extends MY_Model{

    public $table = 'praise';
    public $key = 'id';

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


    public function praise($uid, $sid){
        $this->db->insert($this->table, array('uid' => $uid, 'sid' => $sid, 'create_time' => time()));
        return $this->db->insert_id();
    }

    public function isPraise($uid, $sid){

        $this->db->where('uid', $uid);
        $this->db->where('sid', $sid);
        $this->db->where('create_time >', strtotime('today'));
        $query = $this->db->get($this->table);
        if($query->num_rows() > 0){
            return true;
        }

        return false;
    }


}
