首页 > 解决方案 > Doctrine_Query 中的问题

问题描述

以下 PHP/Doctrine 查询无法正常工作

$q = Doctrine_Query::create();
$q->from('EEvaluationround ER');
$q->leftJoin('ER.EEvaluationroundUser ERU');
$q->where('ER.job_id = ? and ER.active = 1 and (ERU.user_id = ? or ER.leader_user_id = ?)', array($this->job_id, $user->user_id, $user->user_id));
$res = $q->execute();

schema.yml我们有这个

EEvaluationround:
  tableName: e_evaluationround
  columns:
    evaluationround_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    job_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    roundtype_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      default: '10'
      notnull: true
      autoincrement: false
    leader_user_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      default: '0'
      notnull: true
      autoincrement: false
    autoadd:
      type: integer(1)
      fixed: false
      unsigned: true
      primary: false
      default: '0'
      notnull: true
      autoincrement: false
    active:
      type: integer(1)
      fixed: false
      unsigned: true
      primary: false
      default: '1'
      notnull: true
      autoincrement: false
    evaluationround_name:
      type: string(30)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    Job:
      local: job_id
      foreign: job_id
EEvaluationroundUser:
  tableName: e_evaluationround_user
  columns:
    evaluationround_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: false
    user_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: false
    active:
      type: integer(1)
      fixed: false
      unsigned: true
      primary: false
      default: '1'
      notnull: true
      autoincrement: false
  relations:
    EEvaluationround:
      local: evaluationround_id
      foreign: evaluationround_id

左连接语法是否有任何问题,它在日志中抛出以下错误

[Thu Mar 25 07:37:31.544467 2021] [php7:notice] [pid 15834] [client 10.202.9.10:18298] 未知的记录属性/相关组件“

\nalias : EEvaluationround\nforeign : evaluationround_id\nlocal :
evaluationround_id\nclass : EEvaluationround\ntype : 0\ntable : Object(EEvaluationroundTable)\nlocalTable
: 对象(EEvaluationroundUserTable)\nname : \nrefTable : \nonDelete : \nonUpdate : \ndeferred :
\ndeferrable : \nconstraint : \nequal : \ncascade : Array\nowningSide : \nrefClassRelationAlias :
\nforeignKeyName : \norderBy : \n
” 关于“EEvaluationroundUser”,引用者:

[Thu Mar 25 07:37:31.544608 2021] [php7:error] [pid 15834] [client 10.202.9.10:18298] PHP 致命错误:无法声明类 Swift,因为该名称已在 /home/project/ 中使用代码/symfony/lib/vendor/symfony/lib/vendor/swiftmailer/classes/Swift.php 第 18 行,引用者:

标签: phpdoctrine-orm

解决方案


推荐阅读