我在where子句中得到错误未知数组。我知道$项目是一个数组,但我怎么能在where子句中修复这个问题?(我正在使用codeigniter)。
<?php
function rapport_detail_opbrengsten($idKlant) {
$this->db->from('Project');
$this->db->join('Opbrengsten', 'Opbrengsten.idProject = Project.idProject');
if ($idKlant > 0) {
$this->db->where('idKlant', $idKlant);
}
$query = $this->db->get();
$project = array();
foreach ($query->result() as $row) {
$project[] = $row->idProject;
}
$test[] = $project;
$this->db->select('idProject, SUM(Prijs) as total');
$this->db->from('Opbrengsten');
$this->db->where_in('idProject', $test);
$this->db->group_by('idProject');
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result();
} else {
return false;
}
}
?>
答案 0 :(得分:0)
应该是$test[0]
而不是$test