/** * Test loadAssocList method. * * @return void * * @since 11.4 */ public function testLoadAssocList() { $query = $this->object->getQuery(true); $query->select('title'); $query->from('jos_dbtest'); $this->object->setQuery($query); $result = $this->object->loadAssocList(); $this->assertThat($result, $this->equalTo(array(array('title' => 'Testing'), array('title' => 'Testing2'), array('title' => 'Testing3'), array('title' => 'Testing4'))), __LINE__); }
/** * Load log types and prepare them as an array with options. * * <code> * $filters = new CrowdFundingFilters(JFactory::getDbo()); * $options = $filters->getLogTypes(); * </code> * * @return array */ public function getLogTypes() { $query = $this->db->getQuery(true); $query->select("a.type AS value, a.type AS text")->from($this->db->quoteName("#__crowdf_logs", "a"))->group("a.type"); $this->db->setQuery($query); $types = $this->db->loadAssocList(); if (!$types) { $types = array(); } return $types; }
/** * Load a assoc list of database rows * * @param string $key field name of a primary key * @throws SPException * @return array If <var>key</var> is empty as sequential list of returned records. */ public function loadAssocList($key = null) { try { $r = $this->db->loadAssocList($key); $this->count++; } catch (Exception $e) { } if ($this->db->getErrorNum()) { throw new SPException($this->db->stderr()); } else { return $r; } }
/** * Query to database * @param JBDatabaseQuery $select * @param bool $isOne * @param bool $toArray * @return mixed */ protected function _query(JBDatabaseQuery $select, $isOne = false, $toArray = false) { //jbdump::sql($select); $selectSql = (string) $select; $this->app->jbdebug->sql($selectSql); $this->_db->setQuery($selectSql); if (!$toArray) { if ((bool) $isOne) { $result = $this->_db->loadObject(); } else { $result = $this->_db->loadObjectList(); } } else { if ((bool) $isOne) { $result = $this->_db->loadAssoc(); } else { $result = $this->_db->loadAssocList(); } } return $result; }