I have this doctrine query in symfony. It returns a lot of rows when i run mysql code generated by this dql query in phpBB but when i run it in symfony and access its results with this code:
foreach ($this->courses as $course){
echo "<br>".$course->firstname;}
it returns only one name. Also when i try to get $course->title, this error appears Unknown record property / related component "title" on "Students"
Query:
$q= Doctrine_Query::create()
->select('s.firstname,
s.middlename,
s.lastname,
p.program,
c.title,
pc.year')
->from('Students s')
->leftJoin('s.Programs p')
->leftJoin('p.Programcourses pc')
->leftJoin('pc.Courses c')
->where("idstudents = ?",2);
$this->courses=$q->execute();
schema.yml:
Courses:
connection: doctrine
tableName: courses
columns:
idcourses:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
title:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
Programcourses:
local: idcourses
foreign: idcourses
type: many
Programcourses:
connection: doctrine
tableName: programcourses
columns:
idprogramcourses:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
idprograms:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
idcourses:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
year:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
Courses:
local: idcourses
foreign: idcourses
type: one
Programs:
local: idprograms
foreign: idprograms
type: one
Programs:
connection: doctrine
tableName: programs
columns:
idprograms:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: false
program:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
Programcourses:
local: idprograms
foreign: idprograms
type: many
Students:
local: idprograms
foreign: idprograms
type: many
Roles:
connection: doctrine
tableName: roles
columns:
idroles:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: false
role:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
Students:
connection: doctrine
tableName: students
columns:
idstudents:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
firstname:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
middlename:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
lastname:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
idprograms:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
session:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
username:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
password:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
email:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
Programs:
local: idprograms
foreign: idprograms
type: one
Teachers:
connection: doctrine
tableName: teachers
columns:
idteachers:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
firstname:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
lastname:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
username:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
password:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
email:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false