开发者

how to join eav table in table_method

I have the following schema.yml:

JosJeventsVevdetail:
  connection: doctrine
  tableName: jos_jevents_vevdetail
  columns:
    evdet_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    rawdata:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    CustomField: { class: JosJeventsVevdetail, local: evdet_id, fo开发者_如何学编程reign: evdet_id, type: one, foreignType: many }


JosJevCustomfield:
  connection: doctrine
  tableName: jos_jev_customfields
  columns:
    id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    evdet_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      default: '0'
      notnull: true
      autoincrement: false
    name:
      type: string(255)
      fixed: false
      unsigned: false
      primary: false
      default: ''
      notnull: true
      autoincrement: false
    value:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false

I.e. there are many name/value pairs that are matched with a single record in JosJeventsVevdetail.

I'm trying to flatten this with a table method ( and some other tables) like this:

return $q->
    innerJoin("$rootAlias.Event e")->
    innerJoin("e.EventDetail ed")->
    innerJoin("ed.CustomField cf")->
    innerJoin("$rootAlias.JoomlaUser u")->
    innerJoin("u.Person p")->
    innerJoin("$rootAlias.Status s")->
    innerJoin("$rootAlias.RsvpType rt")->
    addWhere("cf.name=?",'preconExams')-> //this removed works,but query wrong
    addSelect("$rootAlias.*, e.*, ed.*, s.*, rt.*, u.*, p.*, cf.*");

but I get an error message "Unknown column name". When I remove cf.name='preconExams', the query runs, but jos_jev_customfields is not joined in the query.

Is there anything wrong with the schema?


what is wrong is the class of your relation. It shoud be JosJevCustomfield and you've put JosJeventsVevdetail ;-) . JosJeventsVevdetail has no column name, hence the error.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜