pairs() static public method

Fetches an associative array of all rows as key-value pairs (first column is the key, second column is the value).
static public pairs ( string $query, array $params = NULL ) : array
$query string query string
$params array query parameters
return array
コード例 #1
0
ファイル: apply_config.php プロジェクト: nperezg/pumilio
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// From http://us3.php.net/header
#Set all as utf-8 for DB
header('Content-Type: text/html; charset=utf-8');
$queryutf = "SET NAMES 'utf8' COLLATE 'utf8_unicode_ci'";
$result = mysqli_query($connection, $queryutf) or die("Could not execute query. Please try again later.");
#Get variables from db - new way
# using
# https://github.com/Xeoncross/DByte
// We need this!
require 'libs/DB/DB.php';
// Create a new PDO connection to MySQL
$pdo = new PDO("mysql:dbname={$database};host={$host}", "{$user}", "{$password}", array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8", PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
use DByte\DB;
DB::$c = $pdo;
$settings = DB::pairs('SELECT `Settings`, `Value` FROM `PumilioSettings`');
extract($settings, EXTR_OVERWRITE);
#Test settings variables
if ($app_custom_name == "") {
    $app_custom_name = "Pumilio";
}
if (!isset($googlemaps_ver)) {
    $googlemaps_ver = "";
}
if ($googlemaps_ver == "") {
    if ($use_googlemaps == "3") {
        $googlemaps_ver = "3";
    }
}
if ($app_custom_text == "") {
    $app_custom_text = "Pumilio is a free and open source sound archive manager for the visualization and manipulation of sound files.";