Php 点火器处于什么状态
我正在使用codeigniter活动记录查询条件中的位置Php 点火器处于什么状态,php,mysql,sql,codeigniter,Php,Mysql,Sql,Codeigniter,我正在使用codeigniter活动记录查询条件中的位置 <?php foreach($std->result() as $stds_id) { $stid[] = $stds_id->std_id; print_r($stid); } 我不知道如何通过考试 我的模型: $this->db->select('*'); $this->db->where_in($field,$id);
<?php
foreach($std->result() as $stds_id) {
$stid[] = $stds_id->std_id;
print_r($stid);
}
我不知道如何通过考试
我的模型:
$this->db->select('*');
$this->db->where_in($field,$id);
$getdata=$this->db->get($table);
return $getdata;
您的代码看起来很好,只需取出在foreach中生成的数组
$stid = array();
foreach($std->result() as $stds_id) {
$stid[] = $stds_id->std_id;
}
$this->db->select('*');
$this->db->from('table');
$this->db->where_in('stid', $stid);
$this->db->get();
return $this->db->result();
将您的
foreach
循环替换为以下内容
foreach ($std->result() as $stds_id) {
$stid[] = $stds_id->std_id;
}
print_r($stid);
并使用此查询查询条件中的位置
$this->db->where_in('stid', $stid);
您的查询正常,
$stid
也正常。只需在foreach
循环外打印它。只需在foreach循环后调用model函数
$this->db->where_in('stid', $stid);