我正在使用codeigniter latestversion,我已经安装了phpactiverecord版本0.0.2,
但是当我用这种方法从数据库中检索数据时
$users = Users::find('all') // return nothing
i did var_dump($users);
output::
array (size=2)
0 =>
object(Users)[39]
public 'errors' => null
private 'attributes' (ActiveRecord\Model) =>
array (size=9)
'id' => null
'username' => null
'email' => null
'password' => null
'active' => int 0
'activation' => null
'ip' => null
'created' => null
'lastaccess' => null
private '__dirty' (ActiveRecord\Model) => null
private '__readonly' (ActiveRecord\Model) => boolean false
private '__relationships' (ActiveRecord\Model) =>
array (size=0)
empty
private '__new_record' (ActiveRecord\Model) => boolean true
1 =>
object(Users)[40]
public 'errors' => null
private 'attributes' (ActiveRecord\Model) =>
array (size=9)
'id' => null
'username' => null
'email' => null
'password' => null
'active' => int 0
'activation' => null
'ip' => null
'created' => null
'lastaccess' => null
private '__dirty' (ActiveRecord\Model) => null
private '__readonly' (ActiveRecord\Model) => boolean false
private '__relationships' (ActiveRecord\Model) =>
array (size=0)
empty
private '__new_record' (ActiveRecord\Model) => boolean true
我想弄清楚问题是什么,,,请帮助
///// Model
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Users extends ActiveRecord\Model {
public function __construct() {
parent::__construct();
}
}
/* End of file user.php */
/* Location: ./application/models/user.php */
?>
///// Controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class User extends MY_Controller {
public function __construct() {
parent::__construct();
}
public function index()
{
$user = Users::all();
var_dump($user);
foreach ($user as $u) {
echo $u->username.'<br/>';
}
## Rendering the view
$this->template->view($this->temp, array('page'=>'backend/users'), NULL);
}
}
/* End of file users.php */
/* Location: ./application/controllers/users.php */
?>
////// Autoload
$autoload['sparks'] = array('php-activerecord/0.0.2');
答案 0 :(得分:0)
完全从__construct()
型号
Users
功能