Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.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
Join 在symfony中加入查询_Join_Symfony1_Doctrine - Fatal编程技术网

Join 在symfony中加入查询

Join 在symfony中加入查询,join,symfony1,doctrine,Join,Symfony1,Doctrine,我有两个表userdetails和blog问题模式是什么 UserDetails: connection: doctrine tableName: user_details columns: id: type: integer(8) fixed: false name: type: string(255) fixed: false BlogQuestion: connection: doctrine table

我有两个表userdetails和blog问题模式是什么

UserDetails:
  connection: doctrine
  tableName: user_details
  columns:
    id:
      type: integer(8)
      fixed: false
    name:
      type: string(255)
      fixed: false

BlogQuestion:
  connection: doctrine
  tableName: blog_question
  columns:
    question_id:
      type: integer(8)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    blog_id:
      type: integer(8)
      fixed: false
    user_id:
      type: integer(8)
      fixed: false
    question_title:
      type: string(255)
我使用一个连接查询来检索这两个表中的所有问题和用户详细信息。我的连接查询是

$q = Doctrine_Query::create()
    ->select('*')
    ->from('BlogQuestion u')
    ->leftJoin('u.UserDetails p');
    $q->execute();
但它显示了此错误未知关系别名UserDetails

谁能帮帮我


提前感谢

你为什么不在你的教义中建立关系

UserDetails:
  connection: doctrine
  tableName: user_details
  columns:
    id:
      type: integer(8)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true

BlogQuestion:
  connection: doctrine
  tableName: blog_question
  columns:
    question_id:
      type: integer(8)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    blog_id:
      type: integer(8)
      fixed: false
    user_id:
      type: integer(8)
      fixed: false
    question_title:
      type: string(255)
  relations:
    UserDetails:
      local: user_id

在你离开join时,你的yml中没有任何东西可以告诉你应该链接什么。我刚刚自己构建了这个,它确实有效

谢谢,但是当我运行symfony原则时:build--all--no confirmation它在路径BlogQuestion->columns->userdetails中显示了一个名为“Local”的错误无效模式元素,并且它显示了相同的错误无效模式元素名为“Local”在路径BlogQuestion->columns->UserDetailswait 20分钟后,我将在办公室检查我的代码,尽管我已经删除了上面的大写字母“L”和小写字母“L”。您可能还需要将UserDetails中的id设置为主键。UserDetails:connection:doctrine tableName:user_details columns:id:type:integer(8)fixed:false unsigned:false primary:true autoincrement:true autoincrement:trueHello THOmas,我刚刚构建了我在上面编辑过的新版本,它确实有效。(现在在部署之前删除它:))