私はこのクエリを作成しようとしています:
SELECT
re . *, t.tipo, m.patente, o.nombre, de.revisado
FROM
sdriving_registros_emisores re
LEFT JOIN
sdriving_turno t ON re.idturno = t.idturno
LEFT JOIN
sdriving_maquina_emisor me ON me.idmaquinaemisor = re.maquinaemisorid
LEFT JOIN
sdriving_maquina m ON me.idmaquina = m.idmaquina
LEFT JOIN
sdriving_operador o ON re.idoperador = o.idoperador
LEFT JOIN
sdriving_detalle_emisores de ON de.idregistros = re.idregistros
WHERE
o.idempresa = 1
Doctrine DQL を使用します。これは私が作ったコードです:
Doctrine_Core::getTable('SdrivingRegistrosEmisores')
->createQuery('re')
->leftJoin('re.SdrivingTurno t')
->leftJoin('re.SdrivingMaquinaEmisor me')
->leftJoin('me.SdrivingMaquina m')
->leftJoin('re.SdrivingOperador o')
->leftJoin('re.SdrivingDetalleEmisores de')
->execute();
しかし、追加するwhere('o.idempresa', $id_empresa)
と、次のエラーが発生します。
SQLSTATE [42S22]: 列が見つかりません: 1054 不明な列 'o.idempresa' が 'where 句' にあります
これを行う適切な方法は何ですか?何が恋しい?
EDIT schema.yml ファイルを追加しました:
SdrivingDetalleEmisores:
connection: doctrine
tableName: sdriving_detalle_emisores
actAs: [Timestampable]
columns:
iddetalle_emisores:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: true
idregistros:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: false
fecha_registro:
type: timestamp(25)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
dertalle_mensaje:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
estado:
type: integer(8)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
revisado:
type: integer(1)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
modo:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
remitente:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
SdrivingRegistrosEmisores:
local: idregistros
foreign: idregistros
type: one
SdrivingEmisor:
connection: doctrine
tableName: sdriving_emisor
actAs: [Timestampable]
columns:
idemisor:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: true
idempresa:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: false
numero:
type: string(50)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
SdrivingEmpresa:
local: idempresa
foreign: idempresa
type: one
SdrivingMaquinaEmisor:
local: idemisor
foreign: idemisor
type: many
SdrivingEmpresa:
connection: doctrine
tableName: sdriving_empresa
columns:
idempresa:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: true
idlogotipo:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: false
nombre_empresa:
type: string(250)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
ruta_emp:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
SdrivingLogotipo:
local: idlogotipo
foreign: idlogotipo
type: one
SdrivingEmisor:
local: idempresa
foreign: idempresa
type: many
SdrivingMaquina:
local: idempresa
foreign: idempresa
type: many
SdrivingOperador:
local: idempresa
foreign: idempresa
type: many
SdrivingTurno:
local: idempresa
foreign: idempresa
type: many
SfGuardUserProfile:
local: idempresa
foreign: idempresa
type: many
SdrivingLogotipo:
connection: doctrine
tableName: sdriving_logotipo
columns:
idlogotipo:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: true
archivo:
type: string(250)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
SdrivingEmpresa:
local: idlogotipo
foreign: idlogotipo
type: many
SdrivingMaquina:
connection: doctrine
tableName: sdriving_maquina
actAs: [Timestampable]
columns:
idmaquina: { type: integer(8), fixed: false, unsigned: false, primary: true, autoincrement: true }
idempresa: { type: integer(4), fixed: false, unsigned: true, primary: true, autoincrement: false }
patente: { type: string(12), fixed: false, unsigned: false, primary: false, notnull: true, autoincrement: false }
relations:
Empresa:
local: idempresa
class: SdrivingEmpresa
type: one
foreignType: one
foreignAlias: MaquinaEmpresa
onDelete: CASCADE
onUpdate: CASCADE
Emisor:
local: idmaquina
class: SdrivingMaquinaEmisor
type: many
foreignType: many
foreignAlias: MaquinaEmisor
onDelete: CASCADE
onUpdate: CASCADE
SdrivingMaquinaEmisor:
connection: doctrine
tableName: sdriving_maquina_emisor
actAs: [Timestampable]
columns:
idmaquinaemisor:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: true
idmaquina:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: false
idemisor:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: false
relations:
SdrivingEmisor:
local: idemisor
foreign: idemisor
type: one
SdrivingMaquina:
local: idmaquina
foreign: idmaquina
type: one
SdrivingRegistrosEmisores:
local: idmaquinaemisor
foreign: maquinaemisorid
type: many
SdrivingOperador:
connection: doctrine
tableName: sdriving_operador
actAs: [Timestampable]
columns:
idoperador:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: true
idempresa:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: false
nombre:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
rut:
type: string(12)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
SdrivingEmpresa:
local: idempresa
foreign: idempresa
type: one
SdrivingRegistrosEmisores:
local: idoperador
foreign: idoperador
type: many
SdrivingRegistrosEmisores:
connection: doctrine
tableName: sdriving_registros_emisores
actAs: [Timestampable]
columns:
idregistros:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: true
maquinaemisorid:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: false
idoperador:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: false
idturno:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: false
relations:
SdrivingTurno:
local: idturno
foreign: idturno
type: one
SdrivingOperador:
local: idoperador
foreign: idoperador
type: one
SdrivingMaquinaEmisor:
local: maquinaemisorid
foreign: idmaquinaemisor
type: one
SdrivingDetalleEmisores:
local: idregistros
foreign: idregistros
type: many
SdrivingTurno:
connection: doctrine
tableName: sdriving_turno
actAs: [Timestampable]
columns:
idturno:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: true
idempresa:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: false
tipo:
type: string(30)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
SdrivingEmpresa:
local: idempresa
foreign: idempresa
type: one
SdrivingRegistrosEmisores:
local: idturno
foreign: idturno
type: many
SfGuardUserProfile:
connection: doctrine
tableName: sf_guard_user_profile
columns:
id: { type: integer(8), primary: true }
user_id: { type: integer(8), primary: false }
idempresa: { type: integer(4), primary: false }
relations:
User:
local: user_id
class: sfGuardUser
type: one
foreignType: one
foreignAlias: SfGuardUserProfile
onDelete: CASCADE
onUpdate: CASCADE