public function GetTotalAmountByCave(Gyuser_Model_Cheques $obj) { $table = $this->getDbTable(); $select = $table->select(); $select->setIntegrityCheck(false); $select->from(array('ops' => 'operations'), array('cave_id', 'liquidacion_id')); $select->joinLeft(array('cqu' => 'cheques'), 'cqu.operation_id = ops.id', array('sum(cqu.amount) as total_amount')); $select->where('ops.cave_id = ?', $obj->getCave_id()); $select->where('cqu.status = ?', $obj->getStatus()); $row = $table->fetchRow($select); return $row->total_amount; }