_getSubSelectEventsCount() . ')'; return $columns; } protected function _getSubSelectEventsCount() { $sql = 'SELECT COUNT(*) ' . 'FROM ' . $this->_getPair('Event') . ' ' . 'WHERE ' . $this->quoteField('doc_number', 'Event') . ' = ' . $this->quoteField('doc_number'); return $sql; } function isNumberUnique($docnumber) { $sql = "SELECT COUNT(*) FROM {$this->tableNameDB} WHERE doc_number = ".$this->db->quote($docnumber); if ($this->id){ $sql .= ' AND id != '.$this->db->quote($this->id); } return !(bool)$this->db->queryOne($sql) ; } function initFromForm(Form $form) { $data = $form->exportValues(); $this->_initDateFromForm($form, $data); $this->initFromArray($data, array()); return true; } /** * @return MDB2_BufferedResult_mysql */ public function getReportStatement() { $sql = 'SELECT ' . ' `' . $this->tableName . '`.*, ' . ' `DEventDocStatus`.`title` AS `status_title` ' . 'FROM ' . $this->_getPair() . ' ' . 'LEFT JOIN ' . $this->_getPair('DEventDocStatus') . ' ' . ' ON `DEventDocStatus`.`id` = ' . $this->quoteField('status_id') . ' ' . 'WHERE 1 ' . 'ORDER BY ' . $this->quoteField('doc_number'); return $this->db->query($sql); } }