Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在where条件下比较多个ID_Php_Mysql_Sql_Codeigniter - Fatal编程技术网

Php 如何在where条件下比较多个ID

Php 如何在where条件下比较多个ID,php,mysql,sql,codeigniter,Php,Mysql,Sql,Codeigniter,我在我的$temp中有多个ID,比如(7,8,9),我想在我的where条件中比较这些ID,比如$this->db->where\u in('c.mr\u no',$temp)但它只比较第一个id 我试着这样做: 控制器: public function printCollectionRecPage() { $this->load->view('template/header'); $this->load->view('template/sidebar')

我在我的
$temp
中有多个ID,比如(7,8,9),我想在我的where条件中比较这些ID,比如
$this->db->where\u in('c.mr\u no',$temp)但它只比较第一个id

我试着这样做:

控制器:

public function printCollectionRecPage()
{
    $this->load->view('template/header');
    $this->load->view('template/sidebar');

    $temp    =($_GET['id']); 
    $data    = array();

    $data['collnR'] = $this->PayRecAllModel->printCollectionRecPage($temp);

    $this->load->view('crossing/payment_rec_allocation/printCollectionRecovery',$data);
    $this->load->view('template/footer');
}
public function printCollectionRecPage($temp)
{
    $this->db->select('c.*,payment_rec_allocn.*');
    $this->db->from('crossing_cash_memo c');
    $this->db->join('payment_rec_allocn', 'payment_rec_allocn.mr_no = c.mr_no');
    $this->db->where('c.total !=','0');
    $this->db->where('c.mr_no',$temp);
    $query = $this->db->get();
    return $query->result();
}    
型号:

public function printCollectionRecPage()
{
    $this->load->view('template/header');
    $this->load->view('template/sidebar');

    $temp    =($_GET['id']); 
    $data    = array();

    $data['collnR'] = $this->PayRecAllModel->printCollectionRecPage($temp);

    $this->load->view('crossing/payment_rec_allocation/printCollectionRecovery',$data);
    $this->load->view('template/footer');
}
public function printCollectionRecPage($temp)
{
    $this->db->select('c.*,payment_rec_allocn.*');
    $this->db->from('crossing_cash_memo c');
    $this->db->join('payment_rec_allocn', 'payment_rec_allocn.mr_no = c.mr_no');
    $this->db->where('c.total !=','0');
    $this->db->where('c.mr_no',$temp);
    $query = $this->db->get();
    return $query->result();
}    

我想在where条件下比较所有3个ID

我认为您收到了来自$\u GET的字符串,因此比较没有按预期进行

改变这个

$this->db->where('c.mr_no',$temp);


然后试试看Where_in将参数排除在数组之外。

$this->db->Where_in('c.mr_no',$temp)。Mkae sure
$temp=数组(7,8,9)
@AnantSingh---AlivetoDie我用where_in
$this->db->where_in('c.mr_no',$temp)但它仍然只比较第一个id(7)@farhantechno,然后它是什么?它是像
$temp=“7,8,9”
这样的字符串吗?@farhantechno您是如何存储它们的?把代码给我们看。