本文整理汇总了PHP中JDatabase::loadAssocList方法的典型用法代码示例。如果您正苦于以下问题:PHP JDatabase::loadAssocList方法的具体用法?PHP JDatabase::loadAssocList怎么用?PHP JDatabase::loadAssocList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JDatabase
的用法示例。
在下文中一共展示了JDatabase::loadAssocList方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: query
/**
* 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;
}
示例2: queryList
/**
* 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();
}
示例3: loadAssocList
/**
* 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));
}
示例4: queryAssocList
/**
* 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);
}
示例5: loadAssocList
/**
* 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;
}
}
示例6: createDBConfig
/**
* 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;
}