【发布时间】:2012-02-22 20:07:27
【问题描述】:
我想选择然后var_dump 数据库行,但我不能,因为var_dump 正在返回bool(false)。
我的模型:(players.php)。
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Players extends CI_Model
{
private $table_name = 'players';
function __construct()
{
parent::__construct();
}
function get($id = FALSE)
{
$this->db->select();
$this->db->where('ban <', time());
if ( $id )
$this->db->where('id =', $id);
$query = $this->db->get($this->table_name);
return $query->num_rows() == 0;
}
}
/* End of file test.php */
/* Location: ./application/models/test.php */
我的 player.php 控制器:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Player extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->load->library('tank_auth');
}
public function index()
{
$this->load->model('players');
$this->load->view('template/header');
$this->load->view('default');
var_dump($this->players->get());
$this->load->view('template/footer');
}
}
/* End of file player.php */
/* Location: ./application/controllers/player.php */
你有什么解决办法吗?
【问题讨论】:
标签: codeigniter activerecord select