まず、MySQL データベースを使用して Symfony2 で Doctrine2 を使用しています。私は次のエンティティを持っています。ご覧のとおり、他のエンティティと関係があります。
Pge\IncidenciasBundle\Entity\Incidencia:
type: entity
table: incidencia
repositoryClass: Pge\IncidenciasBundle\Entity\IncidenciaRepository
id:
id:
type: integer
generator:
strategy: IDENTITY
fields:
fechaInicio:
type: date
nullable: false
column: fecha_inicio
fechaFinal:
type: date
nullable: true
column: fecha_final
horaInicio:
type: time
nullable: true
column: hora_inicio
horaInicioIndisp:
type: time
nullable: true
column: hora_inicio_indisp
horaFinal:
type: time
nullable: true
column: hora_final
horaFinalIndisp:
type: time
nullable: true
column: hora_final_indisp
causa:
type: text
nullable: true
resumen:
type: string
length: 250
fixed: false
nullable: true
descripcion:
type: text
nullable: true
solucion:
type: text
nullable: true
remedy:
type: string
length: 250
fixed: false
nullable: true
accionesRealizadas:
type: text
nullable: true
column: acciones_realizadas
manyToOne:
prioridad:
targetEntity: Prioridad
estado:
targetEntity: Estado
indisponibilidad:
targetEntity: Indisponibilidad
cliente:
targetEntity: Cliente
inversedBy: incidencia
servicio:
targetEntity: Servicio
lifecycleCallbacks: { }
この出力で、特定の日付のデータを取得するクエリを作成しようとしています (画像は html の手作りのテーブルです)
したがって、それぞれについて、各行にテーブルをCliente
印刷し、見つかったものごとにカウンターを印刷する必要がServicio
あります。Prioridad
Incidencia
Incidencia
Prioridad = P0
Prioridad = P1
Prioridad = P3
Servicio = KOSMOS
Cliente = Someone
Someone
SERVICIO P0 P1 P2 P3
KOSMOS 3 1 0 2
それは簡単ですが、私の問題は、このクエリを生成する方法が見つからないことです...いくつかのforeachsといくつかのクエリ用のものを使用して複数の配列を作成しようとしました。Cliente
分離された配列を作成し、与えられた各日付、サービスの配列などですが、数える方法を見つけることができませんPrioridad
でした.約8つのforeach、foreach内のクエリなどがあるため、明らかに良い習慣ではありません...あまり良くありませんが、私は本当に迷ってる…
これを行う簡単な方法があるに違いないと思いますが、私の知る限りではありません...