Hello experts,

I am trying to implement a MySQL query with Zend_DB. The query is:

select s.sid, s.name, r.rid, r.rdate, c.name, s.status from student as s, registration as r, student_course_interests as sc, course as c where s.sid=r.sid and s.sid=sc.sid and c.cid=sc.cid

When I execute this query in the MySQL client, I get the desired result. I tried various types of queries with ZF. I don't understand why Zend_DB changes the column positions. The below query doesn't seem to select s.name at all.

[code]

$select = $db->select();
$select->from(array('s' => 'student'),
            array('s.sid','s.name','s.status'));
$select->join(array('r' => 'registration'),
             's.sid = r.sid',
             array('r.rid','r.rdate'));
$select->join(array('sc' => 'student_course_interests'),
             's.sid = sc.sid');
$select->join(array('c' => 'course'),
             'c.cid = sc.cid',
             array('c.name'));
$result = $db->fetchAll($select);

[/code]

How can I fix this?

Any help is greatly appreciated.

Regards,
Sudheer

Reply via email to