Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 连接语法错误_Php_Mysql_Symfony_Doctrine Orm_Doctrine - Fatal编程技术网

Php 连接语法错误

Php 连接语法错误,php,mysql,symfony,doctrine-orm,doctrine,Php,Mysql,Symfony,Doctrine Orm,Doctrine,我正在用自己的框架编写CMS,使用Doctrince2.5+ 我的数据库表如下所示: 项目表格: +---------------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------------+-------------+------+-----+---------+---

我正在用自己的框架编写CMS,使用Doctrince2.5+

我的数据库表如下所示:

项目
表格:

+---------------------+-------------+------+-----+---------+-------+
| Field               | Type        | Null | Key | Default | Extra |
+---------------------+-------------+------+-----+---------+-------+
| id                  | int(11)     | NO   | PRI | NULL    |       |
| owner_id            | int(11)     | NO   | MUL | NULL    |       |
| item_id             | int(7)      | NO   | MUL | NULL    |       |
| count               | bigint(20)  | NO   |     | NULL    |       |
| money               | varchar(32) | NO   |     | NULL    |       |
| name                | varchar(32) | NO   |     | NULL    |       |
+---------------------+-------------+------+-----+---------+-------+
+------------------------+----------------------+------+-----+---------+-------+
| Field                  | Type                 | Null | Key | Default | Extra |
+------------------------+----------------------+------+-----+---------+-------+
| Id                     | int(11)              | NO   | PRI | 0       |       |
| name                   | varchar(35)          | NO   | UNI |         |       |
| age                    | int                  | NO   |     |         |       |
+------------------------+----------------------+------+-----+---------+-------+
人员
表格:

+---------------------+-------------+------+-----+---------+-------+
| Field               | Type        | Null | Key | Default | Extra |
+---------------------+-------------+------+-----+---------+-------+
| id                  | int(11)     | NO   | PRI | NULL    |       |
| owner_id            | int(11)     | NO   | MUL | NULL    |       |
| item_id             | int(7)      | NO   | MUL | NULL    |       |
| count               | bigint(20)  | NO   |     | NULL    |       |
| money               | varchar(32) | NO   |     | NULL    |       |
| name                | varchar(32) | NO   |     | NULL    |       |
+---------------------+-------------+------+-----+---------+-------+
+------------------------+----------------------+------+-----+---------+-------+
| Field                  | Type                 | Null | Key | Default | Extra |
+------------------------+----------------------+------+-----+---------+-------+
| Id                     | int(11)              | NO   | PRI | 0       |       |
| name                   | varchar(35)          | NO   | UNI |         |       |
| age                    | int                  | NO   |     |         |       |
+------------------------+----------------------+------+-----+---------+-------+
我宣布的模型如下:
Item.php

class Item{
    /** @id @Column(type="integer", name="id")**/
    public $id;
    /** @Column(type="integer", name="owner_id")**/
    public $owner_id;
    /** @Column(type="integer", name = "item_id")**/
    public $item_id;
    /** @Column(type="bigint", name = "count")**/
    public $count;
    /** @Column(type="string", name = "money")**/
    public $money;
    /** @Column(type="string", name = "name")**/
    public $name;
}
 class Person{
        /** @id @Column(type="integer", name="Id")**/
        public $id;
        /** @Column(type="string", name="name", unique=true)**/
        public $name;
        /** @Column(type="integer", name="age")**/
        public $age;
 }
Pesron.php

class Item{
    /** @id @Column(type="integer", name="id")**/
    public $id;
    /** @Column(type="integer", name="owner_id")**/
    public $owner_id;
    /** @Column(type="integer", name = "item_id")**/
    public $item_id;
    /** @Column(type="bigint", name = "count")**/
    public $count;
    /** @Column(type="string", name = "money")**/
    public $money;
    /** @Column(type="string", name = "name")**/
    public $name;
}
 class Person{
        /** @id @Column(type="integer", name="Id")**/
        public $id;
        /** @Column(type="string", name="name", unique=true)**/
        public $name;
        /** @Column(type="integer", name="age")**/
        public $age;
 }
如上所述,我在这里没有关联。 我的DQl是:

    $qb = $this->em->createQueryBuilder();  
    $qb->select('i.id,i.item_id,i.enchant_level, i.owner_id,p.char_name,p.id')
        ->from('Item','i');
        $qb->join('Person','p','WITH','i.owner_id == p.id');    
条令无法解析DQL。 为什么?我查看了文档的文档,但不知道为什么。 如果不使用
则结果是错误的。

提前感谢。

原则是正确的-这不是有效的DQL,因为您使用的是双等于(=)。你可能想要这个:

$qb->join('Person','p','WITH','i.owner_id = p.id'); 

sg-的回答很可能是正确的。作为旁注:你为什么不使用正确的教义关系?非常感谢我们的帮助。我是说你的帮助