Fetches one row in an object of type Zend_Db_Table_Row_Abstract,
or returns null if no row matches the specified criteria.
public fetchRow ( string | array | Zend_Db_Table_Select $where = null, string | array $order = null, integer $offset = null ) : Zend_Db_Table_Row_Abstract | null | ||
$where | string | array | Zend_Db_Table_Select | OPTIONAL An SQL WHERE clause or Zend_Db_Table_Select object. |
$order | string | array | OPTIONAL An SQL ORDER clause. |
$offset | integer | OPTIONAL An SQL OFFSET value. |
Результат | Zend_Db_Table_Row_Abstract | null | The row results per the Zend_Db_Adapter fetch mode, or null if no row found. |
public function getAttribute($id) { if (isset($this->_attributes[$id])) { return $this->_attributes[$id]; } elseif (is_numeric($id)) { $attribute = $this->_attributeModel->find($id)->current(); } else { $where = $this->_attributeModel->select()->where($this->_attributeFieldName . ' = ?', $id); $attribute = $this->_attributeModel->fetchRow($where); } $this->cacheAttribute($attribute); return $attribute; }
/** * */ public function get_sort_categories_parents($parentId, $children = array(), $cur_level = 0) { $res_ar = array(); $parent = parent::fetchRow('id=' . $parentId)->toArray(); $parent['level'] = $cur_level; $Product = new Product(); $c = $Product->getProductCount($parent['children']); $parent['c_count'] = $c; $res_ar = array_merge(array($parent), $children); if ($parent['parentId'] > 0) { $res_ar = $this->get_sort_categories_parents($parent['parentId'], $res_ar, $cur_level - 1); } return $res_ar; }
public function loadRow($value, $field = false) { $select = $this->table->select(); //$this->table->getAdapter()->quote($v) // Check if value is an array if (is_array($value)) { foreach ($value as $k => $v) { $select->where("`$k` = ?", $v); } } else { if (!$field) { $field = $this->table->getPrimary(); } $select->where("`$field` = ?", $value); } $this->row = $this->table->fetchRow($select); }
/** * Find by slug * * @param string $slug * @return App_Table */ public function findBySlug($slug) { $select = $this->select(); $select->where('slug = ?', $slug); return parent::fetchRow($select); }
/** Fetch one result * @access public * @param array $where * @param string $order * @return Object */ public function fetchRow($where = null, $order = null) { $id = md5($where->__toString()); if (!$this->_cache->test($id) || !$this->cache_result) { $result = parent::fetchRow($where, $order); $this->_cache->save($result); return $result; } else { return $this->_cache->load($id); } }
/** * (non-PHPdoc) * @see Zend_Db_Table_Abstract::fetchRow() */ public function fetchRow($where = null, $order = null, $offset = null) { $row = parent::fetchRow($where, $order, $offset); return $row; }
/** * 取得最后一条记录 * * @return ZtChart_Model_Db_Table_Row */ public function lastRow() { return parent::fetchRow(null, array_map(function ($primary) { return $primary . ' DESC'; }, $this->info(parent::PRIMARY))); }