Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/56.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
Mysql 条令加入_Mysql_Symfony_Doctrine Orm - Fatal编程技术网

Mysql 条令加入

Mysql 条令加入,mysql,symfony,doctrine-orm,Mysql,Symfony,Doctrine Orm,用户实体: <?php namespace App\Entity; use App\Entity; use Doctrine\ORM\Mapping; /** * @Entity * @Table(name="users", options={"collate":"utf8_general_ci", "charset":"utf8", "engine":"MyISAM"}) */ class Users extends Entity { /** * @Col

用户实体:

<?php

namespace App\Entity;

use App\Entity;
use Doctrine\ORM\Mapping;

/**
 * @Entity
 * @Table(name="users", options={"collate":"utf8_general_ci", "charset":"utf8", "engine":"MyISAM"})
 */
class Users extends Entity {

    /**
     * @Column(type="string", length=50)
     * @var string
     */
    protected $email;

    /**
     * @Column(type="string", length=50)
     * @var string
     */
    protected $encrypted_password;

    /**
     * @Column(type="string", length=10)
     * @var string
     */
    protected $salt;

    /**
     * @Column(type="smallint", options={"default":"0","comment":"0 : Doctor, 1 : Assistant, 2 : Student"}))
     * @var smallint
     */
    protected $type;

    /**
     * @Column(type="string", length=150)
     * @var string
     */
    protected $sef_link;

    /**
     * @return string
     */
    public function getEmail() {
        return $this->email;
    }

    /**
     * @param string $email
     */
    public function setEmail($email) {
        $this->email = $email;
    }

    /**
     * @return string
     */
    public function getEncryptedPassword() {
        return $this->encrypted_password;
    }

    /**
     * @param string $encrypted_password
     */
    public function setEncryptedPassword($encrypted_password) {
        $this->encrypted_password = $encrypted_password;
    }

    /**
     * @return string
     */
    public function getSalt() {
        return $this->salt;
    }

    /**
     * @param string $salt
     */
    public function setSalt($salt) {
        $this->salt = $salt;
    }

    /**
     * @return integer
     */
    public function getType() {
        return $this->type;
    }

    /**
     * @param integer $type
     */
    public function setType($type) {
        $this->type = $type;
    }

    /**
     * @return string
     */
    public function getSefLink() {
        return $this->sef_link;
    }

    /**
     * @param string $sef_link
     */
    public function setSefLink($sef_link) {
        $this->sef_link = $sef_link;
    }
}
我想用用户信息左键加入一对一用户

用户信息将uid作为唯一密钥,并引用用户id


在uid=用户id的情况下,我如何离开连接并从用户信息获取数据?

您必须在实体之间创建关系。 如果您想要一个oneToOne关系:

class User
{
    /**
     * @ORM\Id
     */
    protected $id;

    /**
     * @ORM\OneToOne(targetEntity="UserInformation")
     */
    protected $userInformation;
}

class UserInformation
{
    /**
     * @ORM\Id
     */
    protected $id;

    /**
     * @ORM\OneToOne(targetEntity="User", inversedBy="userInformation")
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
     */
    protected $uid;
}
内部联接:

$user = $repository
  ->createQueryBuilder('u')
  ->addSelect('ui') // to limit queries when doing $user->getUserInformation()
  ->innerJoin('u.userInformation', 'ui')
  ->where('u.email = :email')->setParameter('email', $email);

您必须在实体之间创建关系。 如果您想要一个oneToOne关系:

class User
{
    /**
     * @ORM\Id
     */
    protected $id;

    /**
     * @ORM\OneToOne(targetEntity="UserInformation")
     */
    protected $userInformation;
}

class UserInformation
{
    /**
     * @ORM\Id
     */
    protected $id;

    /**
     * @ORM\OneToOne(targetEntity="User", inversedBy="userInformation")
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
     */
    protected $uid;
}
内部联接:

$user = $repository
  ->createQueryBuilder('u')
  ->addSelect('ui') // to limit queries when doing $user->getUserInformation()
  ->innerJoin('u.userInformation', 'ui')
  ->where('u.email = :email')->setParameter('email', $email);

“ui WHERE u.email”:错误:Class App\Entity\Users没有名为userInformation的关联您是否有行
受保护的$userInformation?“ui WHERE u.email”:错误:Class App\Entity\Users没有名为userInformation的关联您是否有行
受保护的$userInformation