fetchAll() public method

Honors the Zend_Db_Adapter fetch mode.
public fetchAll ( string | array | Zend_Db_Table_Select $where = null, string | array $order = null, integer $count = null, integer $offset = null ) : Zend_Db_Table_Rowset_Abstract
$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.
$count integer OPTIONAL An SQL LIMIT count.
$offset integer OPTIONAL An SQL LIMIT offset.
return Zend_Db_Table_Rowset_Abstract The row results per the Zend_Db_Adapter fetch mode.
 public function fetchAll()
 {
     $resultSet = $this->dbTable->fetchAll();
     $entries = array();
     foreach ($resultSet as $row) {
         $entries[] = array('id' => $row->id, 'state' => $row->state, 'info' => $row->info, 'lastupdate' => $row->lastupdate, 'sticked' => $row->sticked);
     }
     return $entries;
 }
Example #2
0
 public function getAll()
 {
     $resultSet = $this->dbTable->fetchAll();
     $resultTab = array();
     foreach ($resultSet as $enreg) {
         $modelClassName = 'Application_Model_' . $this->className;
         $result = new $modelClassName();
         $result->fromArray($enreg);
         $resultTab[] = $result;
     }
     return $resultTab;
 }
Example #3
0
 /**
  * Find admin
  *
  * @param int $applicationId
  * @param string $username
  * @param Admin_Model_Admin $admin
  * @return boolean
  */
 public function find($applicationId, $username, Admin_Model_Admin $admin)
 {
     $select = $this->_dbTable->select();
     $select->setIntegrityCheck(false)->from(array('a' => 'admin'), array('a.*'))->joinLeft(array("aa" => "admin_application"), "aa.admin_id = a.id")->where('a.username = ?', $username)->where('aa.application_id = ?', $applicationId);
     $resultSet = $this->_dbTable->fetchAll($select);
     if (0 == count($resultSet)) {
         return false;
     }
     //get first row from resultSet
     $row = $resultSet->current();
     $admin->setOptions($row->toArray());
     return true;
 }
Example #4
0
 public function isValid($value)
 {
     $db = $this->_model->getAdapter();
     $where = $db->quoteInto($this->_field . ' = ?', $value);
     if (null !== $this->_where) {
         $where .= " AND {$this->_where}";
     }
     $rows = $this->_model->fetchAll($where);
     if (count($rows)) {
         $this->_messages[] = Axis::translate('core')->__("Record %s already exist", $value);
         return $this->_not;
     }
     $this->_messages[] = Axis::translate('core')->__("Record %s doesn't found", $value);
     return !$this->_not;
 }
Example #5
0
 /**
  * Load ACL rules from DB and load them in a Zend_Acl instance.
  *
  * @return Zend_Acl
  */
 protected function _loadAcl()
 {
     $this->_roles = $this->_roleTable->fetchAll();
     $this->_rules = $this->_ruleTable->fetchAll();
     $this->_resources = $this->_resourceTable->fetchAll();
     foreach ($this->_roles as $role) {
         $this->_loadRole($role);
     }
     foreach ($this->_resources as $resource) {
         $resourceID = null;
         $module = $resource->module;
         $controller = $resource->controller;
         if ($module != null && $controller != null) {
             $resourceID = $module . '.' . $controller;
         }
         if ($resourceID != null && !$this->has($resourceID)) {
             $this->add(new Zend_Acl_Resource($resourceID));
         }
     }
     foreach ($this->_rules as $rule) {
         $resourceID = null;
         $module = $rule->module;
         $controller = $rule->controller;
         if ($module != null && $controller != null) {
             $resourceID = $module . '.' . $controller;
         }
         if ((bool) $rule->allow) {
             $this->allow($rule->role, $resourceID, $rule->action);
         } else {
             $this->deny($rule->role, $resourceID, $rule->action);
         }
     }
     return $this;
 }
Example #6
0
 public function fetchAll($where = null, $order = null, $count = null, $offset = null)
 {
     $select = $this->getQueryAll();
     if ($where) {
         $select->where($where);
     }
     return parent::fetchAll($select);
 }
Example #7
0
 /**
  * Lazy load data via table fetchAll() method.
  *
  * @return void
  */
 protected function loadData()
 {
     if ($this->data === null) {
         $this->data = $this->_table->fetchAll($this->_where, $this->_order, $this->_count, $this->_offset);
         if ($this->data instanceof Zend_Db_Table_Rowset_Abstract) {
             $this->data = $this->data->toArray();
         }
     }
 }
Example #8
0
 /**
  * This is overridden to handle cache
  * 
  * (non-PHPdoc)
  * @see library_Zend/Db/Table/Zend_Db_Table_Abstract#fetchAll($where, $order, $count, $offset)
  */
 public function fetchAll($where = null, $order = null, $count = null, $offset = null)
 {
     $name = $this->_name . '_' . md5($where);
     $data = $this->loadCache($name);
     if (!$data) {
         $data = parent::fetchAll($where, $order, $count, $offset);
         $this->saveCache($data, $name);
     }
     return $data;
 }
Example #9
0
 /**
  * get enabled or disabled applications
  *
  * @param int $_state can be Tinebase_Application::ENABLED or Tinebase_Application::DISABLED
  * @return Tinebase_Record_RecordSet list of applications
  */
 public function getApplicationsByState($_status)
 {
     if ($_status !== Tinebase_Application::ENABLED && $_status !== Tinebase_Application::DISABLED) {
         throw new Tinebase_Exception_InvalidArgument('$_status can be only Tinebase_Application::ENABLED or Tinebase_Application::DISABLED');
     }
     $where[] = $this->_db->quoteInto($this->_db->quoteIdentifier('status') . ' = ?', $_status);
     $rowSet = $this->_applicationTable->fetchAll($where);
     $result = new Tinebase_Record_RecordSet('Tinebase_Model_Application', $rowSet->toArray(), TRUE);
     return $result;
 }
Example #10
0
 /**
  * wrapper around Zend_Db_Table_Abstract::fetchAll
  *
  * @param strin|array $_where OPTIONAL
  * @param string $_order OPTIONAL
  * @param string $_dir OPTIONAL
  * @param int $_count OPTIONAL
  * @param int $_offset OPTIONAL
  * @throws Tinebase_Exception_InvalidArgument if $_dir is not ASC or DESC
  * @return the row results per the Zend_Db_Adapter fetch mode.
  */
 public function fetchAll($_where = NULL, $_order = NULL, $_dir = 'ASC', $_count = NULL, $_offset = NULL)
 {
     if ($_dir != 'ASC' && $_dir != 'DESC') {
         throw new Tinebase_Exception_InvalidArgument('$_dir can be only ASC or DESC');
     }
     $order = NULL;
     if ($_order !== NULL) {
         $order = $_order . ' ' . $_dir;
     }
     $rowSet = parent::fetchAll($_where, $order, $_count, $_offset);
     return $rowSet;
 }
Example #11
0
 function fetchAll($where = null, $order = null, $count = null, $offset = null)
 {
     if (!is_object($where) || $where instanceof Zend_Db_Table_Select) {
         return parent::fetchAll($where, $order, $count, $offset);
     } else {
         if (!$where instanceof Zend_Db_Select) {
             throw new Exception("Mauvais type de requête");
         } else {
             throw new Exception("Qui sait traiter ça ? " . gettype($where));
         }
     }
 }
Example #12
0
 /**
  * (non-PHPdoc)
  * @see Zend_Db_Table_Abstract::fetchAll()
  */
 public function fetchAll($where = null, $order = null, $count = null, $offset = null)
 {
     if (empty($where)) {
         $tableName = $this->getTableName();
         if (false == ($rows = App_Cache::load($tableName))) {
             $rows = parent::fetchAll($where, $order, $count, $offset);
             App_Cache::save($rows, $tableName);
         }
     } else {
         $rows = parent::fetchAll($where, $order, $count, $offset);
     }
     $rows = parent::fetchAll($where, $order, $count, $offset);
     return $rows;
 }
 /**
  * wrapper around Zend_Db_Table_Abstract::fetchAll
  *
  * @param string|array $_where OPTIONAL
  * @param string $_order OPTIONAL
  * @param string $_dir OPTIONAL
  * @param int $_count OPTIONAL
  * @param int $_offset OPTIONAL
  * @throws Tinebase_Exception_InvalidArgument if $_dir is not ASC or DESC
  * @return array the row results per the Zend_Db_Adapter fetch mode.
  */
 public function fetchAll($_where = NULL, $_order = NULL, $_dir = 'ASC', $_count = NULL, $_offset = NULL)
 {
     if ($_dir != 'ASC' && $_dir != 'DESC') {
         throw new Tinebase_Exception_InvalidArgument('$_dir can be only ASC or DESC');
     }
     $order = NULL;
     if ($_order !== NULL) {
         $order = $_order . ' ' . $_dir;
     }
     // possibility to tracing queries
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE) && ($config = Tinebase_Core::getConfig()->logger)) {
         if ($config->traceQueryOrigins) {
             $e = new Exception();
             Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . "\n" . "BACKTRACE: \n" . $e->getTraceAsString() . "\n" . "SQL QUERY: \n" . $this->select()->assemble());
         }
     }
     $rowSet = parent::fetchAll($_where, $order, $_count, $_offset);
     return $rowSet;
 }
 /**
  * loadDestinationData
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0 
  */
 private function loadDestinationData()
 {
     try {
         $objSelect = $this->objTable->select();
         $objSelect->setIntegrityCheck(false);
         $arrFields = array($this->strDBFLft, $this->strDBFRgt, $this->strDBFDepth);
         if (!is_null($this->strDBFParent)) {
             $arrFields[] = $this->strDBFParent;
         }
         if (!is_null($this->strDBFRoot)) {
             $arrFields[] = $this->strDBFRoot;
         }
         $objSelect->from($this->objTable->info(Zend_Db_Table_Abstract::NAME), $arrFields);
         $objSelect->where('id = ?', $this->intDestinationId);
         $this->objDestinationData = $this->objTable->fetchAll($objSelect);
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }
Example #15
0
 /** Fetch all data
  * @access public
  * @param array $where
  * @param string $order
  * @param string $count
  * @param integer $offset
  * @return array
  */
 public function fetchAll($where = null, $order = null, $count = null, $offset = null)
 {
     $id = md5($where->__toString());
     if (!$this->_cache->test($id) || !$this->cache_result) {
         $result = parent::fetchAll($where, $order, $count, $offset);
         $this->_cache->save($result);
         return $result;
     } else {
         return $this->_cache->load($id);
     }
 }
Example #16
0
 /**
  *
  */
 public function get_sort_categories_children($parentId, $levels, $cur_level = 0)
 {
     $res_ar = array();
     $Product = new Product();
     if ($levels > 0) {
         //$sel = $this->select()->from(array('a' => $this->_name,)->where('parentId='.$parentId);
         $children = parent::fetchAll('parentId=' . $parentId)->toArray();
         //$children = parent::fetchAll($sel)->toArray();
         //$children = $this->getAll(array('where' => 'a.parentId='.$parentId));
         //print_r($children);exit;
         foreach ($children as $key => $child) {
             $child['level'] = $cur_level;
             $ar_children = $this->get_sort_categories_children($child['id'], $levels - 1, $cur_level + 1);
             if (count($ar_children) <= 0) {
                 $product_count = $Product->getProductCount($child['children']);
                 $child['c_count'] = $product_count;
             } else {
                 $c = 0;
                 foreach ($ar_children as $one_child) {
                     $c += $one_child['c_count'];
                 }
                 $child['c_count'] = $c;
             }
             if ($child['c_count'] > 0) {
                 $res_ar[] = $child;
             }
             $res_ar = array_merge($res_ar, $ar_children);
         }
     }
     return $res_ar;
 }
Example #17
0
 public function execute($select)
 {
     return parent::fetchAll($select);
 }
Example #18
0
 /**
  * (non-PHPdoc)
  * @see Zend_Db_Table_Abstract::fetchAll()
  */
 public function fetchAll($where = null, $order = null, $count = null, $offset = null)
 {
     $rows = parent::fetchAll($where, $order, $count, $offset);
     return $rows;
 }
Example #19
0
 /**	@brief FetchAll.
  * Permet d'obtenir un tableau BIDIMENTIONNEL pour chaque ligne de résultat de la forme :
  * array(array('key_1' => "Valeur 1", 'key_2' => "Valeur 2", ... , 'key_Z => "Valeur Z")).
  *
  * @li La clé est l'occurence de la ligne de résultat.
  * @li La valeur est un tableau associatif entre le nom du champ et sa valeur en base.
  * @li Aucune ligne de résultat n'est écrasée par une autre : les données sont brutes.
  *
  * @param	object|string	$pSelect		: objet Zend_Db_Select ou string Sql.
  * @throws	lève une exception de type Zend_Exception en cas d'erreur de requete.
  * @return	array retourne tableau représentant chaque ligne de résultat sous forme array('key'=>"value").
  */
 public function fetchAll($pSelect)
 {
     try {
         return parent::fetchAll($pSelect)->toArray();
     } catch (Exception $e) {
         throw new Zend_Exception("BAD_QUERY", __METHOD__, $e);
     }
 }
Example #20
0
    /**
     * Get a page
     *
     * @var int $page
     * @return Zend_Db_Table_Rowset_Abstract
     */
    public function getPage($page)
    {
        $this->_select->limitPage((int) $page, $this->getRowLimit());

        return $this->_table->fetchAll($this->_select);
    }
Example #21
0
 /**
  * Switch fetch method to support hasManyAndBelongsToMany relationship.
  *
  * @param string|array $where  Where clause.
  * @param string|array $order  Order clause.
  * @param string|array $count  Limit.
  * @param string|array $offset Offset.
  *
  * @return Zend_Db_Table_Rowset The rowset with the results.
  */
 protected function _fetchWithOutJoin($where = null, $order = null, $count = null, $offset = null)
 {
     if (array_key_exists('hasManyAndBelongsToMany', $this->_relations) && is_array($this->_relations['hasManyAndBelongsToMany'])) {
         return $this->_fetchHasManyAndBelongsToMany($where);
     } else {
         // Collect all the fields for prevent select *
         $select = $this->select()->from($this->_name, $this->_cols);
         if (null !== $where) {
             $select->where($where);
         }
         if (null !== $order) {
             $select->order($order);
         }
         if ($count !== null || $offset !== null) {
             $select->limit($count, $offset);
         }
         return parent::fetchAll($select);
     }
 }
Example #22
0
 public function fetchAll($where = null, $order = null, $count = null, $offset = null)
 {
     $where = $this->_appendProtectedCondition($where);
     return parent::fetchAll($where, $order, $count, $offset);
 }
Example #23
0
 /**
  * Count.
  * ! NOTE we call the fetchAll of the parent here.
  * So this might not performe good at the moment
  *
  * @return integer Count of results.
  */
 public function count()
 {
     return parent::fetchAll()->count();
 }