« Return to Thread: Adding SELECT options to Zend_Db_Select

Adding SELECT options to Zend_Db_Select

by Hector Virgen :: Rate this Message:

Reply to Author | View in Thread

Is there a way to add SELECT options to a Zend_Db_Select object? For example, I want to be able to produce the following SELECT statement:

SELECT SQL_CALC_FOUND_ROWS * FROM table LIMIT 10;

More generally, I need a way to add options between the "SELECT" and the column list. I know there is a built-in method to add "DISTINCT" but MySQL also supports many other modifiers such as SQL_NO_CACHE, SQL_BIG_RESULT, HIGH_PRIORITY, etc.

http://dev.mysql.com/doc/refman/5.0/en/select.html

I'm almost certain that all of the options are not supported by all of the various database engines, so if there was a method that allowed you to pass in your options by argument it could come in very handy. For example:

$select = $table->select()->addOption('SQL_NO_CACHE')->addOption('HIGH_PRIORITY')->from(......

Technically, this would also allow "DISTINCT" to be added using addOption().

I've considered subclassing Zend_Db_Select to handle this, but I would have to redefine __toString() to support this.

-Hector

 « Return to Thread: Adding SELECT options to Zend_Db_Select