duanpoqiu0919 2014-01-06 18:34
浏览 59

phpactiverecord - Users :: find('all')返回空数组 - 版本0.0.2

i am using codeigniter latestversion and i have installed phpactiverecord version 0.0.2,

however when i retrieved data from database with this method

$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

i am trying to figure out what is the problem ,,, any help please

///// 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');
  • 写回答

1条回答 默认 最新

  • doubo82706 2014-05-03 14:34
    关注

    Remove the __construct() function entirely from the Users model

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大