Php 如何在codeigniter中使用条令查询生成器?
我有一个问题: 我使用的是条令2和代码点火器2。我想知道条令查询生成器是如何工作的?我想在条令查询生成器上使用select查询,但我做不到。我也读过条令文件并尝试过,但没有成功 尝试此操作后,我收到以下错误消息: 致命错误:未捕获异常“条令\ORM\Query\QueryException”,消息为“选择u.username、u.password、u.email FROM Entity\Userss u,在C:\xampp\htdocs\hotell\application\libraries\doctor\ORM\Query\QueryException.php:39堆栈跟踪:0 C:\xampp\htdocs\hotell\application\libraries\doctor\ORM\Query\Parser.php429:doctor\ORM\Query\QueryException::dqlError'SELECT u.userna…'1C:\xampp\htdocs\hotell\application\libraries\Doctrine\ORM\Query\Parser.php854:Doctrine\ORM\Query\Parser->语义错误'Class'Userss'…',数组2 C:\xampp\htdocs\hotell\application\libraries\doctor\ORM\Query\Parser.php1529:doctor\ORM\Query\Parser->AbstractSchemaName 3 C:\xampp\htdocs\hotell\application\libraries\doctor\Query\Parser.php1426:doctor\ORM\Query\Parser->RangeVariableDeclaration 4C:\xampp\htdocs\hotell\application\libraries\doctor\ORM\Query\Parser.php1173:doctor\ORM\Query\Parser->IdentificationVariableDeclaration 5 C:\xampp\htdocs\hotell\applic在C:\xampp\htdocs\hotell\application\libraries\doctor\ORM\Query\Query\QueryException.php第49行 我的实体代码:Php 如何在codeigniter中使用条令查询生成器?,php,codeigniter,doctrine-orm,Php,Codeigniter,Doctrine Orm,我有一个问题: 我使用的是条令2和代码点火器2。我想知道条令查询生成器是如何工作的?我想在条令查询生成器上使用select查询,但我做不到。我也读过条令文件并尝试过,但没有成功 尝试此操作后,我收到以下错误消息: 致命错误:未捕获异常“条令\ORM\Query\QueryException”,消息为“选择u.username、u.password、u.email FROM Entity\Userss u,在C:\xampp\htdocs\hotell\application\libraries\
<?php
namespace Entity;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @Entity
* @Table(name="user")
*/
class Userss
{
/**
* @Id
* @Column(type="integer", nullable=false)
* @GeneratedValue(strategy="AUTO")
*/
public $id;
/**
* @Column(type="string", length=32, unique=true, nullable=false)
*/
public $username;
/**
* @Column(type="string", length=64, nullable=false)
*/
public $password;
/**
* @Column(type="string", length=255, unique=true, nullable=false)
*/
public $email;
/**
* The @JoinColumn is not necessary in this example. When you do not specify
* a @JoinColumn annotation, Doctrine will intelligently determine the join
* column based on the entity class name and primary key.
*
* @ManyToOne(targetEntity="Group")
* @JoinColumn(name="group_id", referencedColumnName="id")
*/
public function setUsername($Username)
{
$this->username = $Username;
}
public function getUsername()
{
return $this->username;
}
// and more...
}
这是我从CI_模型扩展而来的模型中的代码:
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
require_once APPPATH . 'modules/user/models/entity/user_modell.php';
class User_model extends CI_Model
{
public $em;
public function __construct() {
parent::__construct();
$this->em = $this->doctrine->em;
}
function test()
{
$repo = $this->em->getRepository('Entity\\Userss', 'u');
$qb = $repo->createQueryBuilder('u')
->select('u.username, u.password, u.email')
->from('Userss', 'u')
->orderBy('u.username', 'ASC')
->getQuery()->getArrayResult();
var_dump($qb);
die;
}
}
试着改变
->getQuery()->getArrayResult();
进入
它对我有效。你看到了吗:?是的,我阅读并应用了此文档,但我得到了相同的错误:它有效!我评论这个:名称空间实体;但我不知道它的原因。。。
->getQuery()->getResult();