function findDocuments() { $t = new Documents(); $db = $t->getAdapter(); $s = $t->select()->setIntegrityCheck(false)->distinct()->from('document')->join('unite_document', 'unite_document.document = document.id', array())->joinLeft(array('parent' => 'unite'), $db->quoteInto('parent.id = ?', $this->parent), array())->where('unite_document.unite IN (?, parent.id, parent.parent)', $this->id)->order('date DESC'); return $t->fetchAll($s); }
function findDocument() { $t = new Documents(); $db = $t->getAdapter(); $s = $t->select()->setIntegrityCheck(false)->distinct()->from('document')->join('article_document', 'article_document.document = document.id', array())->where('article_document.article = ?', $this->id)->limit(1); return $t->fetchOne($s); }