Ejemplo n.º 1
0
 /**
  * returns a single record matching the search crit.
  * If several records match the crit wil return the first one based on the sort param.
  * Note the variation that versioning inserts into the process
  *
  * @param scalar[] $searchCrit
  * @param string $sort
  * @return Zupal_Content_IDomain
  */
 public function findOne($searchCrit = NULL, $sort = NULL, $pDomain = FALSE)
 {
     $table = $this->table();
     $id_field = $table->idField();
     $node_field = $this->node_field();
     $select = $this->_select($searchCrit, $sort, $pDomain);
     if ($pDomain) {
         $row = $table->fetchRow($select);
         return $this->get($row);
     } else {
         if ($this->_is_versioned) {
             $node_stub = Zupal_Nodes::getInstance();
             $cond = sprintf('( `%s`.%s = `%s`.node_id )', $table->tableName(), $this->node_field(), $node_stub->table()->tableName());
             $cond .= sprintf(' AND (`%s`.%s = `%s`.version)', $table->tableName(), $id_field, $node_stub->table()->tableName());
             //@TODO: cache this expression?
             $select->join($node_stub->table()->tableName(), $cond, array());
             $row = $table->getAdapter()->fetchRow($select);
             $id = $row[$id_field];
             // transfer data into domain objects.
             return is_null($id) ? NULL : $this->get($id);
         } else {
             $row = $this->table()->fetchRow($select);
             return $this->get($row);
         }
     }
 }
Ejemplo n.º 2
0
 public function formmakervalidateAction()
 {
     $this->_helper->layout->disableLayout();
     $this->view->table = $this->_getParam('table');
     $this->view->detail = Zupal_Nodes::getInstance()->table()->getAdapter()->fetchAll('DESCRIBE ' . $this->view->table);
 }