Question about QDatagrid

Login or register to post comments
1 reply [Last post]
Offline
Joined: 12/29/2011

im a newbie in qcubed framework..
i just want to ask something about qdatagrid..
i have 2 tables employees and department
employees have columns => id,employeename,departmentid
departments have columns => id,departmentname
i want to know how to display the data in qdatagrid as follows
__________________________________________________
| id | employeename | departmentname |
---------------------------------------------------

thanks in advance...

jmirancid's picture
Offline
Joined: 04/04/2011

Hi marron28,

If you want a "object oriented" answer, which is the best, I suggested to establish the "Foreign Keys" between the tables in your database engine (I don't know if you are using MySQL, SqlLite or other).

Then open the framework and regenerate the ORM Model with the new FK relations.

Later in your development environment you can access to that information like this

<?php
// Getting one Employee Object.
$objEmployees = Employees::Load($intEmployeeNumber);

// Getting Deparment Object in relation with employee
$objDepartment = $objEmployee->objDepartment

$objDeparment
->Name
?>

This is the simplest way to do it, see the generated ORM class in the "model/generated" folder

NOTE: If your tables not have relations and can't establish in the main database engine, QCubed can do it for you! =) in a virtual way.

See the file in "\includes\configuration\codegen_settings.xml" and follow the instructions to do the virtual relations.

Regards, JMI