本文整理汇总了PHP中DBAccess::query方法的典型用法代码示例。如果您正苦于以下问题:PHP DBAccess::query方法的具体用法?PHP DBAccess::query怎么用?PHP DBAccess::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBAccess
的用法示例。
在下文中一共展示了DBAccess::query方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_activity_info
/**
* Update the information of a viewing observer, or player.
**/
function update_activity_info()
{
$sql = new DBAccess();
// ******************** Usage Information of the browser *********************
$remoteAddress = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : NULL;
$userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : NULL;
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL;
// ************** Setting anonymous and player usage information
if (!SESSION::is_set('online')) {
// *** Completely new session, update latest activity log.
if ($remoteAddress) {
// *** Delete prior to trying to re-insert into the people online.
$sql->query("DELETE FROM ppl_online WHERE ip_address='" . $_SERVER['REMOTE_ADDR'] . "'\n\t\t\t\t or session_id = '" . session_id() . "'");
}
// Update viewer data.
$sql->query("INSERT INTO ppl_online (session_id, activity, ip_address, refurl, user_agent) " . "VALUES ('" . session_id() . "', now(), '{$remoteAddress}', '{$referer}', '{$userAgent}')");
SESSION::set('online', true);
} else {
// An already existing session.
if (is_logged_in()) {
// A logged in player, update their activity time
$sql->query("UPDATE ppl_online SET activity=now(), member='y' WHERE session_id='" . session_id() . "'");
} else {
// Un-logged-in observer, as login has not yet occurred.
$sql->query("UPDATE ppl_online SET activity=now() WHERE session_id='" . session_id() . "'");
}
}
}
示例2: remove_array_item
<?php
include_once "db.php";
// SQL
$marques = DBAccess::query("SELECT * FROM marque\n\t WHERE idMarque <> 1129");
// salons
$path = "../../img/salon";
$files = scandir($path);
function remove_array_item($array, $item)
{
$index = array_search($item, $array);
if ($index !== false) {
array_splice($array, $index, 1);
}
return $array;
}
$files = remove_array_item($files, '.');
$files = remove_array_item($files, '..');
$files = remove_array_item($files, 'mini');
$res = array("marques" => $marques, "salons" => $files);
print json_encode($res, JSON_PRETTY_PRINT);
?>
示例3: json_encode
<?php
include_once "db.php";
// SQL
$marques = DBAccess::query("SELECT * FROM marque");
$modeles = DBAccess::query("SELECT * FROM modele\n\tJOIN marque ON modele.idMarque = marque.idMarque");
$response = array();
$response['marques'] = $marques;
$response['modeles'] = $modeles;
print json_encode($response, JSON_PRETTY_PRINT);
示例4: insertAnneeModele
function insertAnneeModele ($version) {
$anneeModele = sqlproof($version["anneeModele"]);
$idModele = $version["idModele"];
$query = "INSERT INTO anneeModele (annee, idModele) VALUES ('$anneeModele', '$idModele')";
print($query . '<br/>');
DBAccess::exec($query);
}
function insertGamme ($version, $idAnneeModele) {
$type = sqlproof($version["type"]);
$nom = sqlproof($version["nom"]);
$query = "INSERT INTO gamme (type, nom, idAnneeModele) VALUES ('$type', '$nom', '$idAnneeModele')";
print($query . '<br/>');
DBAccess::exec($query);
}
*/
$docs = DBAccess::query("SELECT *\n\tFROM a_supprimer_documentVersion, a_supprimer_version\n\tWHERE a_supprimer_documentVersion.idVersion = a_supprimer_version.idVersion AND idModele=4\n");
foreach ($docs as $id => $doc) {
$idDocumentVersion = $doc["idDocumentVersion"];
$idModele = $doc["idModele"];
$anneeModele = sqlproof($doc["anneeModele"]);
$gamme = sqlproof($doc["type"]);
$nomGamme = sqlproof($doc["nom"]);
$ordre = sqlproof($doc["ordre"]);
$source = sqlproof($doc["source"]);
$date = sqlproof($doc["date"]);
$legende = sqlproof($doc["legende"]);
$idGamme = DBAccess::singleValue("SELECT idGamme\n\t\tFROM gamme, anneeModele\n\t\tWHERE gamme.idAnneeModele = anneeModele.idAnneeModele\n\t\t\tAND annee = '{$anneeModele}'\n\t\t\tAND (type='{$gamme}' AND (nom<>'' AND nom='{$nomGamme}'))\n\t\t\tAND idModele = '{$idModele}'\n\t");
if (!$idGamme) {
$idGamme = DBAccess::singleValue("SELECT idGamme\n\t\t\tFROM gamme, anneeModele\n\t\t\tWHERE gamme.idAnneeModele = anneeModele.idAnneeModele\n\t\t\t\tAND annee = '{$anneeModele}'\n\t\t\t\tAND (type='{$gamme}' AND nom='')\n\t\t\t\tAND idModele = '{$idModele}'\n\t\t");
if (!$idGamme) {
$idGamme = DBAccess::singleValue("SELECT idGamme\n\t\t\t\tFROM gamme, anneeModele\n\t\t\t\tWHERE gamme.idAnneeModele = anneeModele.idAnneeModele\n\t\t\t\t\tAND annee = '{$anneeModele}'\n\t\t\t\t\tAND type='{$gamme}'\n\t\t\t\t\tAND idModele = '{$idModele}'\n\t\t\t");
示例5: foreach
<?php
include_once "db.php";
$idModele = $_REQUEST["id"];
// SQL
$marque = DBAccess::singleRow("SELECT * FROM marque WHERE idMarque=(SELECT idMarque FROM modele WHERE idModele='{$idModele}')");
$modele = DBAccess::singleRow("SELECT * FROM modele WHERE idModele='{$idModele}'");
$anneeModeles = DBAccess::query("SELECT * FROM anneeModele WHERE idModele='{$idModele}' ORDER BY annee");
foreach ($anneeModeles as $key => $anneeModele) {
$anneeModeles[$key]['gammes'] = DBAccess::query("SELECT * FROM gamme WHERE idAnneeModele=" . $anneeModele['idAnneeModele']);
foreach ($anneeModeles[$key]['gammes'] as $key2 => $gamme) {
$anneeModeles[$key]['gammes'][$key2]['docs'] = DBAccess::query("SELECT * FROM documentGamme WHERE idGamme='" . $anneeModeles[$key]['gammes'][$key2]['idGamme'] . "' ORDER BY ordre, idDocumentGamme");
}
}
$response = array();
$response['marque'] = $marque;
$response['modele'] = $modele;
$response['anneeModeles'] = $anneeModeles;
print json_encode($response, JSON_PRETTY_PRINT);
示例6: json_encode
<?php
include_once "db.php";
$idMarque = $_REQUEST["id"];
// SQL
$marque = DBAccess::singleRow("SELECT * FROM marque WHERE idMarque='{$idMarque}'");
$modeles = DBAccess::query("SELECT * FROM modele WHERE idMarque='{$idMarque}' ORDER BY ordre");
$documentsMarque = DBAccess::query("SELECT * FROM documentMarque WHERE idMarque='{$idMarque}' ORDER BY ordre");
foreach ($modeles as $id => $modele) {
$idModele = $modele['idModele'];
$modeles[$id]['idDocEmblematique'] = DBAccess::singleValue("\n\t\tSELECT idDocumentGamme\n\t\tFROM documentGamme, gamme, anneeModele\n\t\tWHERE documentGamme.idGamme=gamme.idGamme\n\t\t AND gamme.idAnneeModele=anneeModele.idAnneeModele\n\t\t\tAND idModele='{$idModele}'\n\t\tORDER BY emblem_modele DESC\n\t");
}
$marque['modeles'] = $modeles;
$marque['docs'] = $documentsMarque;
$marque['categories'] = isset($categories) ? $categories : null;
$aText = "texte/marque/{$idMarque}.txt";
if (is_file($aText) && ($desc = implode(file($aText)))) {
//$marque['histo'] = utf8_encode($desc);
$marque['histo'] = $desc;
}
print json_encode($marque, JSON_PRETTY_PRINT);
示例7: foreach
<?php
include_once "db.php";
// SQL
$marques = DBAccess::query("SELECT * FROM marque WHERE collectionne_mini='Y' ORDER BY nomMarque");
foreach ($marques as $id => $marque) {
$idMarque = $marque['idMarque'];
$marques[$id]['modeles'] = DBAccess::query("\n SELECT *\n FROM modele\n WHERE idMarque='{$idMarque}'\n ORDER BY nomModele\n ");
}
$res = array('marques' => $marques);
print json_encode($res, JSON_PRETTY_PRINT);
示例8: json_encode
$result = DBAccess::singleRow("SELECT *\n\t\t\tFROM documentGamme\n\t\t\tJOIN gamme on gamme.idGamme = documentGamme.idGamme\n\t\t\tJOIN anneeModele on gamme.idAnneeModele = anneeModele.idAnneeModele\n\t\t\tJOIN modele on anneeModele.idModele = modele.idModele\n\t\t\tJOIN marque on marque.idMarque = modele.idMarque\n\t\t\tWHERE idDocumentGamme='{$id}'");
}
}
}
}
}
}
}
if ($objet == "marque") {
$result['liste_pays'] = DBAccess::query("SELECT DISTINCT pays FROM marque");
$result['modeles'] = DBAccess::query("SELECT * FROM modele WHERE idMarque = {$id} ORDER BY ordre");
} else {
if ($objet == "modele") {
$result['liste_categories'] = DBAccess::query("SELECT DISTINCT categorie FROM modele ORDER BY categorie");
/*$result['versions'] = DBAccess::query
(
"SELECT * FROM version WHERE idModele = $id ORDER BY ordre, anneeModele"
);*/
} else {
if ($objet == "gamme") {
$result['liste_types'] = DBAccess::query("SELECT DISTINCT type FROM gamme ORDER BY type");
} else {
if ($objet == "docGamme" || $objet == "docMarque") {
$result['liste_sources'] = DBAccess::query("SELECT DISTINCT source\n\t\t FROM\n\t\t (SELECT DISTINCT source\n\t\t FROM documentGamme\n\t\t UNION\n\t\t SELECT DISTINCT source\n\t\t FROM documentMarque)\n\t\t ORDER BY source");
}
}
}
}
$result['action'] = $action;
$result['objet'] = $objet;
print json_encode($result, JSON_PRETTY_PRINT);