用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1928|回复: 2
收起左侧

[版本 2.x] 新手请教如何跟踪到model里面?

[复制链接]
发表于 2013-10-20 10:26:11 | 显示全部楼层 |阅读模式
因为是新手,平时跟踪代码都是echo字符串出来然后判断问题在哪儿,现在的问题在调用model时,程序就没有下文,怀疑是数据插入错误,相关代码如下:
//model的代码
        public function insertbuyer( $buyerinfo )
        {
                echo "8";
                if ( $buyerinfo == FALSE )
                {
                        return NULL;
                }
                echo "6";
                //construct the
                $this->db->insert('buyer',$buyerinfo);       
        }


//controller的代码
        $this->load->model('Buyer_model');
                if ( $type == 'buy')
                                        {
                                                echo "2";
                                                var_dump($data);
                                                $this->Buyer_model->insert_buyer( $data);
                                        }

现在的结果是似乎$this->Buyer_model->insert_buyer( $data);没有生效,因为数据库没有对应的记录,以前使用过controller,但是当时只编写过view和controller,且系统已经搭建好了,只是基于上面做代码,没有遇到这么多问题,谢谢。
发表于 2013-10-20 11:24:37 | 显示全部楼层
database.php db_debug为true时SQL执行错误会打印出来的。

或者model中 打印 $this->db->last_query();看看SQL
发表于 2013-10-20 21:06:42 | 显示全部楼层
在控制器中加上
PHP复制代码
$this->output->enable_profiler(TRUE);
复制代码


会显示所有信息,当然也有数据库相关的

本版积分规则