Doctrine orm 使用codeigniter中的条令从表中获取所有数据
我已经在codeigniter 2中集成了条令2。我在模型/实体中存储了将其转换为实体的数据库 我的控制器是这样的Doctrine orm 使用codeigniter中的条令从表中获取所有数据,doctrine-orm,codeigniter-2,Doctrine Orm,Codeigniter 2,我已经在codeigniter 2中集成了条令2。我在模型/实体中存储了将其转换为实体的数据库 我的控制器是这样的 public function __construct() { parent::__construct(); $this->em = $this->doctrine->em; $this->load->model('doctrine_model'); } public func
public function __construct() {
parent::__construct();
$this->em = $this->doctrine->em;
$this->load->model('doctrine_model');
}
public function index()
{
$this->doctrine_model->get_object();
}
}
模型是这样的
Class Doctrine_model extends CI_Controller
{
function __construct() {
parent::__construct();
//$this->load->library('doctrine');
//$accountTable = Doctrine_Core::getTable('ss_class');
$this->em = $this->doctrine->em;
}
function get_object()
{
$records = $this->em->getRepository("Entity\SsClass")->findAll();
}
}
当我运行这段代码时,我得到了这个错误
Fatal error: Cannot redeclare class SsClass in D:\xampp\htdocs\new_doctrine\application\models\Entity\SsClass.php on line 14
因为我已经在autoload中加载了条令库,但无法弄清楚这里发生了什么…getRepository方法自动加载您的实体,所以您的实体类可能会自动加载到其他位置,例如config.php或require function。我想没有人会回复..:只需在生成的实体类中添加use namespace实体,问题就解决了。。