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

(初学者) 执行数据库访问操作后页面上没有任何反映

[复制链接]
发表于 2013-12-24 13:38:13 | 显示全部楼层 |阅读模式
用以下的代码对postgre数据库做了select查询,在浏览器上输入http://localhost/index.php/weather/select/后页面上不显示任何信息(数据库里是有数据的),哪位帮忙看一下怎么样才能使其在页面上显示信息(比如数据库连接错误、操作错误)?谢谢。

weather.php文件:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Weather extends CI_Controller {
        function select() {
                $this->load->model("weather_m");
                $result=$this->weather_m->select();
                var_dump($result);
                echo $result[0]->city;
        }
}
?>

weather_m.php文件:
<?php

class Weather_m extends CI_Model {

     function __construct() {
         parent::__construct();
         $this->load->database();
     }

     function select() {
             $this->db->select("*");
             $query=$this->db->get("weather");
             return $query->result();
     }
}

?>

 楼主| 发表于 2013-12-26 16:35:16 | 显示全部楼层
a3771273 发表于 2013-12-25 13:06
$this->load->model("weather_m");改成$this->load->model("weather_m",true);试试。还有你得到的是对象, ...

首先感谢你的回复,你说的方法我试过了,问题还是一样的。

我另外测试了一下php连接postgreSQL,发现问题出在这儿。codeIgniter把这个错误给屏蔽掉了。(也许修改某个配置会把屏蔽给去掉?不知道)


本版积分规则