0

Any Ideas how I can build the following query with the zend_db_table class?

SELECT SUM(x) FROM traffic

thanks

2 Answers 2

1

Slightly more descriptive code sample:

$table = new DbTable_Traffic(); //extends Zend_Db_Table
$select = $table->select()->columns('SUM(X)');

Expressions containing () will be transformed to Zend_Db_Expr automatically.

Sign up to request clarification or add additional context in comments.

Comments

0

I don't actually use Zend_Db_Table at all, but if you know how to configure basic queries, use this expression instead

$ZendDBTable->columns(new Zend_Db_Expr('SUM(x)');

Read it as pseudocode, I don't know the syntax of Zend_Db_Table. The new Zend_Db_Expr('some mysql keywords') is used to let the engine know that you have a keyword in the query which should not be escaped.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.