0

我正在使用 symfony 1.4 和教义,我目前在 schema.yml 上为我的 2 个表创建了结构,但是当我进行查询时,我得到了这个异常

SQLSTATE [42S22]:未找到列:1054 'on 子句'中的未知列 'o.id'。查询失败:“SELECT o.id_aditional_details AS o__id_aditional_details, o.name AS o_ name, o.type AS o _type, o.group AS o__group FROM ohrm_aditional_details o INNER JOIN ohrm_details_info o2 ON o.id = o2.ohrm_aditional_details_id WHERE (o2.user = 4)"

我必须要表格,details_info并且aditional_details,附加详细信息需要在其中一个字段中包含 details_info 中一个条目的 id,我不知道这个错误,因为我已经用其他表格完成了,但这次我不知道发生了什么......

我的 schema.yml 是这样的

OhrmAditionalDetails:
  connection: doctrine
  tableName: ohrm_aditional_details
  columns:
    id_aditional_details:
      type: integer(11)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    name:
      type: string(100)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    type:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    group:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
OhrmDetailsInfo:
  connection: doctrine
  tableName:  ohrm_details_info
  columns:
    id_details_info:
      type: integer(11)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    aditional_info:
      type: integer(11)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    result:
      type: string(200)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    user:
      type: integer(11)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    OhrmAditionalDetails:
    local: aditional_info
    foreign: id_aditional_details
    type: one
    HsHrEmployee:
    local: user
    foreign: emp_number
    type: one

和我的查询,很简单

try
{
    $q = Doctrine_Query::create()
        ->select('*')
        ->from('OhrmAditionalDetails D')
        ->innerJoin('D.OhrmDetailsInfo I')
        ->where("I.user = $id");

    $result = $q->execute();
    return $result;
}
catch(Exception $e)
{
    print_r ($e->getMessage());
    return null;
}

在 $id = 4 的情况下

任何想法?我试过了

php symfony cc
php symfony doctrine:build-model
php symfony orangehrm:publish-assets
php symfony cc

但没有...

4

1 回答 1

2

它试图猜测要加入的列的名称,例如寻找id而不是id_aditional_details.

看起来您已经在 schema.yml 中正确定义了它,但它会将其解释为空,因为您没有正确缩进 yaml。尝试:

  relations:
    OhrmAditionalDetails:
      local: aditional_info
      foreign: id_aditional_details
      type: one
    HsHrEmployee:
      local: user
      foreign: emp_number
      type: one
于 2013-05-01T02:59:54.017 回答