Merhaba

class LicenseModel extends Model
{
    protected $table = 'licenses';
    protected $primaryKey = 'id';
    protected $allowedFields = ['product', 'key', 'domain', 'type', 'until'];
    function get_valid_licenses_count() {
        return $this->db->table($this->table)->where('(until > '.time().') OR (until = 0)')->countAllResults();
    }
    function get_license_by_id($id) {
        $id = $this->db->table($this->table)->where("id", $id)->get()->getResultArray();
        return count($id) > 1 ? $id[1] : null;
    }
    function check_license($domain, $product) {
        return $this->db->table($this->table)->where('((domain = "'.trim($domain).'") AND (product = "'.$product.'")) AND ((until > '.time().') OR (until = 0))')->countAllResults()>0;
    }
    function check_license_by_key($domain, $key) {
        return $this->db->table($this->table)->where('((domain = "'.trim($domain).'") AND (key = "'.$key.'")) AND ((until > '.time().') OR (until = 0))')->countAllResults()>0;
    }
}
Bu şekilde denermisin.