Codeigniter查询构建器|子查询执行

时间:2019-03-22 18:32:25

标签: codeigniter query-builder

如何在CodeIgniter查询构建器中获取我的分页的总记录数和结果集。我试图在添加限制之前执行子查询,然后我想添加限制 以下是我的查询

import numpy as np
from scipy.stats import binom

np.random.seed(2019)

N, K = 10000, 1000
tp = np.empty(K)

for i in range(K):
    t = binom(n=N, p=0.01).rvs()
    f = N - t
    detect_t = binom(n=t, p=0.800).rvs()
    detect_f = binom(n=f, p=0.096).rvs()
    tp[i] = detect_t / (detect_f + detect_t)

np.quantile(tp, [0.025, 0.5, 0.975])
# array([0.06177242, 0.07714902, 0.09462359])

在这里我想要结果集计数

$this->db->select('tmsm.question,tmsm.answer,tmsmc.category_name');
$this->db->from('tbl_my_study_materials as tmsm');
$this->db->join('tbl_my_study_material_category as tmsmc','tmsm.category_id=tmsmc.category_id');
$this->db->where('tmsm.is_deleted','0');
$this->db->where('tmsm.category_id',$category_id);
$this->db->like('tmsm.question', $search_term);

然后我要对此查询添加一个限制,然后执行整个查询以获取有限的数据集

$subQuery=$this->db->get_compiled_select();
$totalRecords = count($this->db->query($subQuery)->result());

但是它不起作用

0 个答案:

没有答案