【发布时间】:2013-09-19 03:48:53
【问题描述】:
我无法将我的查询从数据库显示到 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'];
}
【问题讨论】:
-
我还收到一条消息“方法名称必须是字符串”
-
你加载了
model吗? -
哦,是的。从一开始。我加了这个。 $this->load->model('mdl_employee','emp');
标签: php codeigniter