straight join in zend framework

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

Answers


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();

I use this hack of Zend_Db_Select:

$select->from($tableName, array(new Zend_Db_Expr(' STRAIGHT_JOIN ' . $tableName . '.*'));

Hope this helps somebody.


Need Your Help

Send form based on html select error

javascript jquery html

I have a select form that sends the value when you change the select. Unfortunately, everytime it sends it goes back to the option "10". How can I have it (for example) so you can click on the 20 o...

Migrate GWT 2.0.4 Project to GWT 2.1.0

eclipse gwt

I update my Google Plugin (and GWT) version from 2.0.4 to 2.1.0