I have used left join in using zend framework/mysql using Zend_Db_Table::getDefaultAdapter. Does this also support straight join ? If yes, how do i do that? I tried checking in documentation. Couldn't find. Thanks for the help
I use this hack of Zend_Db_Select:
$select->from($tableName, array(new Zend_Db_Expr(' STRAIGHT_JOIN ' . $tableName . '.*'));
Hope this helps somebody.
Looking at the Zend source, it seems that there is no support for a STRAIGHT_JOIN
when using Zend_Db_Select
. You may however write the SQL statement yourself and then execute it directly using the DB adapter:
$db = Zend_Db_Table::getDefaultAdapter();
//Taken from: http://framework.zend.com/manual/en/zend.db.adapter.html#zend.db.adapter.select.fetchall
$sql = 'SELECT * FROM bugs WHERE bug_id = ?';
$result = $db->fetchAll($sql, 2);
If you already have a complicated query using Zend_Db_Select
, you can use the __toString()
method and use that string as a basis for your modified query.
//Taken from: http://framework.zend.com/manual/en/zend.db.select.html#zend.db.select.execute.tostring
$select = $db->select()->from('products');
$sql = $select->__toString();
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.