我无法将我的查询从数据库显示到 CodeIgniter。
我的桌子有“ id
, description
, date_stamp
”。我只想得到date_stamp
.
这是我的代码:
模型
public function get_holidays()
{
$this->db->select('date_stamp');
$this->db->from('holidays');
$query = $this->db->get();
if($query->num_rows() > 0)
{
foreach ($query->result() as $row)
{
$data[] = $query->row();
}
}
else
{
$data = "";
}
return $data;
}
控制器:
$holidays = $this->emp->get_holidays();
//the result should be like this
//$holidays=array("2013-09-20","2013-09-23", "2013-09-25");
foreach($holidays as $holiday){
//
echo $holiday['date_stamp'];
}