提问人:Toni Michel Caubet 提问时间:5/8/2013 最后编辑:Toni Michel Caubet 更新时间:5/8/2013 访问量:156
CodeIgniter:应用程序不工作,不会记录错误
CodeIgniter: Application Doesn't work and wont log errors
问:
我用 CodeIgniter 做的小项目(只是为了熟悉它。这实际上就像他们教程的示例)它停止工作,即使index.php设置为开发,也没有给我任何输出或错误......
所以我试着用一些回声自己调试它
我发现这里停止记录
class News extends CI_Controller {
public function __construct()
{
parent::__construct();
echo 'This is echoed';
$this->load->model('news_model');
echo 'This wont be echoed';
}
/*(class continues)*/
}
我的news_model.php是这样的:
<?php
class News_model extends CI_Model {
public function __construct()
{
$this->load->database();
}
public function get_news($slug = FALSE)
{
if ($slug === FALSE)
{
$query = $this->db->get('news'{});
return $query->result_array();
}
$query = $this->db->get_where('news', array('slug' => $slug));
return $query->row_array();
}
public function set_news()
{
$this->load->helper('url');
$slug = url_title($this->input->post('title'), 'dash', TRUE);
$data = array(
'title' => $this->input->post('title'),
'slug' => $slug,
'text' => $this->input->post('text')
);
return $this->db->insert('news', $data);
}
}
知道我做错了什么吗?
-编辑-
public function __construct()
{
echo '__construct()';
$this->load->database();
echo 'after__construct()';
}
他们都没有得到回应......
答:
1赞
JOE LEE
5/8/2013
#1
找到 1
$this->db->get('news'{}); // try to del {}
第一个参数是表名
第二个和第三个参数使您能够设置限制和偏移子句
评论
0赞
JOE LEE
5/8/2013
@Toni 米歇尔·考贝特 , try to del {}
0赞
karmafunk
5/8/2013
#2
原来的codeignitor教程是这样的:
public function get_news($slug = FALSE)
{
if ($slug === FALSE)
{
$query = $this->db->get('news'); // <----------------------------
return $query->result_array();
}
$query = $this->db->get_where('news', array('slug' => $slug));
return $query->row_array();
}
评论
0赞
karmafunk
5/8/2013
此外,如果您使用 PHP 编辑器,则此错误会突出显示。
评论