dougehe2022 2014-10-02 12:24
浏览 17

Codeigniter Doctrine不使用下划线(_)类名

Hello guys i created Entity folder inside application/model/. In Entity folder i created file Mj_user.php and give class name as same Mj_user.

but when i try to access that class using

$User= new Entity\Mj_user;

it's giving me error

Fatal error: Class 'Entity\Mj_user' not found in C:\xampp\htdocs\project\application\controllers\user.php on line 15

what should i do Please help me..but when i remove Mj_ then put only file name as User.php. Its working properly..Please help me

  • 写回答

1条回答 默认 最新

  • doujupa7567 2014-10-29 17:58
    关注

    When creating a new class you have to be careful, the name of the class must be:

    class Mj_user extends CI_Model {
       function __contruct()
       {
            partent::construct();
       }
    }
    

    The file must be mj_user.php and for using this model you must load it before start using it it can be preloaded for all in the configuration or you can load it whenever you need it like this

    $this->load->view('mj_user');
    

    And in the error seems that is looking for a file called user.php and should be mj_user.php

    评论

报告相同问题?

悬赏问题

  • ¥15 制裁名单20240508芯片厂商
  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接