0

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

SELECT SUM(x) FROM traffic

thanks

Charles
  • 50,943
  • 13
  • 104
  • 142

2 Answers2

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.

Tomáš Fejfar
  • 11,129
  • 8
  • 54
  • 82
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.

mike
  • 5,047
  • 2
  • 26
  • 32