On 7/19/07, José de Menezes Soares Neto <[EMAIL PROTECTED]> wrote:

i have two tables:

tb_employees (id, emp_name, fk_sector)
tb_sectors (id, sec_name)

I need to make a sql query in the tb_employees, and then, print emp_name
and sec_name...
But I don't know how to retrieve this using Zend_DB


What you are looking to do is outlined in the framework documentation at
http://framework.zend.com/manual/en/zend.db.table.relationships.html.
Basically, you need to declare tb_sectors a dependent table of
tb_employees.  After that, you just need to find the tb_employees record
normally:

$employee = $table->find( 1 );

Then, you will be able to get the tb_sectors record associated with the
employee like so:

$sector = $employee->findDependentRowset( 'Tb_sectors' );
echo $employee->emp_name;
echo $sector->sec_name;

Dillon

Reply via email to