Ejemplo n.º 1
0
 /**
  * Returns an associative array of records from a query.
  * 
  * @param $query
  */
 function query($query)
 {
     switch (strtolower(substr(trim($query), 0, 6))) {
         case 'select':
             $this->_db->setQuery($query);
             $results = $this->_db->loadAssocList();
             return $results;
             break;
         case 'insert':
         case 'update':
             $this->_db->setQuery($query);
             $result = $this->_db->query();
             return $result;
             break;
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  * Funzione per eseguire una query e restituire i risultati come array associativo
  * @param string Testo della query
  * @return array
  * FUNZIONE CHIAMATA DAL MODULO DEVE ESSERE SEMPRE IMPLEMENTATA QUI
  */
 public function queryList($q)
 {
     $this->db->setQuery($q);
     return $this->db->loadAssocList();
 }
Ejemplo n.º 3
0
 /**
  * Load a associative array of associative database rows or column values.
  *
  * @param  string  $key     The name of a field on which to key the result array
  * @param  string  $column  [optional] column name. If not null: Instead of the whole row, only this column value will be in the result array
  * @return array            If $key is null: Sequential array of returned records/values, Otherwise: Keyed array
  *
  * @throws  \RuntimeException
  */
 public function loadAssocList($key = null, $column = null)
 {
     return $this->_nullToArray($this->_db->loadAssocList($key, $column));
 }
Ejemplo n.º 4
0
 /**
  * Execute a query to the database and get an array of the result set rows from the database query where each row is an associative array
  *
  * The result returned by this method is the same as the one returned by JDatabase::loadAssocList()
  * Generally used for SELECT operations
  *
  * @param string $query The query to be executed
  * @param string $key The name of a field on which to key the result array
  *
  * @return array The results of the query
  *
  * @throws RuntimeException
  *
  * @since 1.0.0
  */
 public function queryAssocList($query, $key = '')
 {
     // query database table
     $this->_database->setQuery($query);
     return $this->_database->loadAssocList($key);
 }
 /**
  * Load a assoc list of database rows
  * 
  * @param string The field name of a primary key
  * @return array If <var>key</var> is empty as sequential list of returned records.
  */
 function loadAssocList($key = null)
 {
     if ($key == '' || checkJversion() >= 0) {
         $resultArray = $this->_db->loadAssocList($key);
         return $this->_nullToArray($resultArray);
     } else {
         // mambo 4.5.2 - 4.6.2 has a bug in key:
         if (!($cur = $this->query())) {
             return null;
         }
         $array = array();
         while (is_array($row = $this->m_fetch_assoc($cur))) {
             if ($key) {
                 $array[$row[$key]] = $row;
                 //  $row->key is not an object, but an array
             } else {
                 $array[] = $row;
             }
         }
         $this->m_free_result($cur);
         return $array;
     }
 }
Ejemplo n.º 6
0
	/**
	 * Returns a new configuration registry from a source configuration
	 * SQL table. This method uses the JDatabase object.
	 *
	 * @param   JDatabase  $handler  Connected and active JDatabase object.
	 * @param   string     $table    Database table to use.
	 *
	 * @return  JRegistry  Registry of configuration.
	 *
	 * @since   2.0
	 */
	protected static function createDBConfig(JDatabase $handler, $table)
	{
		// Create the registry with a default namespace of config
		$registry = new JRegistry;

		$query = $handler->getQuery(true);

		// Do the SQL query ensuring only platform specific entries are returned
		$query->select($query->quoteName('name'))
			->select($query->quoteName('value'))
			->from($query->quoteName($table))
			->order($query->quoteName('id'));

		$handler->setQuery($query);

		// Load the SQL query into an associative array
		$array = $handler->loadAssocList('name', 'value');

		if (!is_null($array))
		{
			foreach ($array as $key => $value)
			{
				// Ensure compatibility between group.config and group:config
				$registry->set(str_replace(':', '.', $key), $value);
				$registry->set(str_replace('.', ':', $key), $value);
			}
		}

		return $registry;
	}