简体   繁体   中英

Zend join three columns

I have three columns album, album_images, image_name. What I'm trying to do is combine the columns.

I have a problem following code:

$select = $db->select()
->from(array('a' => 'album_images'), array('album_id', 'image_names_id'))
->join(array('b' => 'image_names'), 'a.image_names_id = b.id', array())
->join(array('c' => 'album'), 'c.album = a.album_id', array('id'))
->where('c.id = ?', $id);

When I do this I get the following error:

Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'c.album' in 'on clause'

What did I do wrong?

Just like the message says - there's no "album" column in "album" table. Maybe it should be like:

->join(array('c' => 'album'), 'c.id = a.album_id', array('id'))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM