我有这样的代码
$this->load->model("m_crud");
$test= $this->m_crud->get_querry; //this model already have query and result() to return
foreach($test as $retest)
{
echo $retest->primary_id;
$test2=$this->db->query("select * from table2 where id='$retest");
foreach($test2 as $retest2)
{
echo $retest2->name;
}
}
将所有这些代码放入“视图”很容易,但我想使用 MCV 模型。我尝试使用这样的数组存储结果:
$data['test']=$test
foreach($test as $retest)
{
echo $retest->primary_id;
$test2=$this->db->query("select * from table2 where id='$retest");
$data['test2']=$test2
foreach($test2 as $retest2)
{
echo $retest2->name;
}
}
$this->load->view("test_view",$data);
我在视图中得到的是我从 的回声中具有相同的值,每个人的回声$test2
应该是不同的$test
谢谢,对不起我的英语不好