我正在使用codeigniter,这是我的观点:
<select name="kode_promo_air" id="kode_promo_air" class="span3 input2">
<option value="">-PILIH-</option>
<?php
$data = $this->app_model->get_promo_air();
foreach($data->result() as $t){
?>
<option value="<?php echo $t->PRO_PRICE_CODE;?>"><?php echo $t->PRO_MST_NM;?> - <?php echo $t->PRO_AMT_CUST;?></option>
<?php
}
?>
</select>
这是 app_model -> get_promo_air()
function get_promo_air()
{
$sql = "
SELECT
c.PRO_PRICE_CODE,
a.PRO_MST_NM,
c.PRO_AMT_CUST
FROM
promo_master a
inner join promo_type b on a.pro_type_id = b.pro_type_id
inner join promo_price c on a.PRO_MST_ID = c.PRO_MST_ID
WHERE sysdate() BETWEEN a.PRO_PRICE_DATE_FROM
AND a.PRO_PRICE_DATE_TO
AND b.PRO_TYPE_ID = 1
";
return $this->db->query($sql);
}
问题是我在调试时无法在我的视图中获得 $data->result() :
<?php
$data = $this->app_model->get_promo_air();
echo "<pre>";
print_r($data->result());
die();
?>
<select name="kode_promo_air" id="kode_promo_air" class="span3 input2">
<option value="">-PILIH-</option>
<?php
$data = $this->app_model->get_promo_air();
foreach($data->result() as $t){
?>
<option value="<?php echo $t->PRO_PRICE_CODE;?>"><?php echo $t->PRO_MST_NM;?> - <?php echo $t->PRO_AMT_CUST;?></option>
<?php
}
?>
</select>
我有 :
Array
(
[0] => stdClass Object
(
[PRO_PRICE_CODE] => AAA001001
[PRO_MST_NM] => Promo Air Asia
[PRO_AMT_CUST] => 65000.00
)
[1] => stdClass Object
(
[PRO_PRICE_CODE] => AGI001001
[PRO_MST_NM] => Promo Garuda
[PRO_AMT_CUST] => 40000.00
)
)
如何获得价值?因为我尝试使用foreach($data->result() as $t)
它无法获取数据...任何解决方案将不胜感激..