Hi, This can be a fool question but I can't make my query works.
I have been reading the examples and when I have just one table to do the query it works ok, but in my case I have to return values from different tables in my query and I cant't make it works.
I have this query, for example. In this I use 3 different tables called curs_practiques, persona and practiques_director.
In the case of the table curs_practiques it generated the class CursPractiques. Persona will have to instances, student and teacher, which will be defined in the sql query, anyway persona generated the class Persona, and practiques_director generated PractiquesDirector class.
in my php i have this function to generated the datagrid:
protected function dtgCursPractiques_Bind() {
$strQuery = “SELECT distinct curs_practiques.codi_curs as code, student.nom as name_student,
teacher.nom as name_teacher
from curs_practiques, persona as teacher, persona as student, practiques_director
where curs_practiques.dni = student.dni and practiques_director.num_carnet_director = curs_practiques.num_carnet_director
and practiques_director.dni = teacher.dni”;
$objDatabase = QApplication::$Database[1];
$objDbResult = $objDatabase->Query($strQuery);
$objCursPractiquesArray = CursPractiques::InstantiateDbResult($objDbResult);
$this->dtgCursPractiques->DataSource = ($objCursPractiquesArray);
}
--
and according to the classes it will return:
curs_practiques.codi_curs = code = CursPractiques ->CodiCurs
student.nom = name_student = Persona->Nom
teacher.nom = name_teacher = Persona->Nom
---
Then, to show my datagrid in the page I use something like this:
1.
$this->dtgCursPractiques->AddColumn(...);
But I don't know whcih parameters I have to put there, if I use:
$this->dtgCursPractiques->AddColumn(new QDataGridColumn('curs', '<?= $_ITEM->CodiCurs ?>', 'Width=50')); ->It shows the datagrid but doen's show any value, besides, if I put some of the fileds from a class different to CursPractiques it returns this error message:
Undefined GET property or variable in 'CursPractiques' class:
2. I tried then:
$this->dtgCursPractiques->AddColumn(new QDataGridColumn('curs', '<?= $_ITEM->code ?>', 'Width=50'));
But it returned the same error message.
I'll continue working on it but I wanted to ask here, maybe you can find what's wrong with my code. I hope I have been clear with my explanation
Thank you