ll209 发表于 2008-7-12 08:25:55

插入数据问题

我刚刚学CI,请教一下为什么插不进去数据,代码如下:
<?php
class News extends Controller {
        function News(){
        parent:: Controller();
        $this->load->helper('form');
        }
function index()
{
   $this->load->view('blog/newsview');
}
function create(){
                $arr['title']=$this->input->post('title',true);
                $arr['body']=$this->input->post('body',true);
               $this->db->insert('entries ', $arr);
                   redirect('blog/newsview');
                }               
        }

?>
插入数据时,报错如下:
A PHP Error was encountered
Severity: Notice

Message: Undefined property: News::$db

Filename: controllers/news.php

Line Number: 20

Fatal error: Call to a member function insert() on a non-object in E:\webpage\CodeIgniter\system\application\controllers\news.php on line 20
请高的指教一下.

Hex 发表于 2008-7-12 09:31:07

你 $this->load->database() 了吗?
页: [1]
查看完整版本: 插入数据问题