|
用以下的代码对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(); } } ?> | |