本文整理汇总了PHP中getDbConnection函数的典型用法代码示例。如果您正苦于以下问题:PHP getDbConnection函数的具体用法?PHP getDbConnection怎么用?PHP getDbConnection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getDbConnection函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getProduct
function getProduct($id)
{
$connection = getDbConnection();
$sql = <<<EOT
SELECT p.`id`, p.`name`, p.description, p.price, p.image
FROM products AS p
WHERE p.id = {$id}
EOT;
$result = mysqli_query($connection, $sql);
return $result->fetch_row();
}
示例2: searchForKeyword
function searchForKeyword($keyword)
{
$db = getDbConnection();
$stmt = $db->prepare("SELECT name as beer FROM `beers` WHERE name LIKE ? ORDER BY name LIMIT 5;");
$keyword = '%' . $keyword . '%';
$stmt->bindParam(1, $keyword, PDO::PARAM_STR, 100);
$isQueryOk = $stmt->execute();
$results = array();
if ($isQueryOk) {
$results = $stmt->fetchAll(PDO::FETCH_COLUMN);
} else {
trigger_error('Error executing statement.', E_USER_ERROR);
}
$db = null;
return $results;
}
示例3: doIt
/**
* Echoes some stuff
*/
function doIt()
{
if ($this->foo_name == 'Bar') {
$res = globalDoIt();
echo $res;
}
//в простых случаях {} можно опускать
if ($this->foo_name == 'Test') {
return;
}
//логически сгруппированный блок кода
$db = getDbConnection();
$it = $db->exec('select * from a');
foreach ($it as $record) {
echo $record->get('id');
}
$i++;
}
示例4: searchForKeyword
function searchForKeyword($keyword)
{
$db = getDbConnection();
//$stmt = $db->prepare("SELECT DISTINCT tag_name FROM `tags` WHERE tag_name LIKE ? ORDER BY tag_name");
//$stmt = $db->prepare("SELECT DISTINCT word FROM `dictionary` WHERE word LIKE ? ORDER BY word");
$stmt = $db->prepare("SELECT DISTINCT tag_name FROM `tags` WHERE tag_name LIKE ? ORDER BY tag_name");
$stmt2 = $db->prepare("SELECT DISTINCT word FROM `dictionary` WHERE word LIKE ? ORDER BY word");
$keyword = $keyword . '%';
$stmt->bindParam(1, $keyword, PDO::PARAM_STR, 100);
$stmt2->bindParam(1, $keyword, PDO::PARAM_STR, 100);
$isQueryOk = $stmt->execute();
$isQueryOk2 = $stmt2->execute();
$results = array();
if ($isQueryOk && $isQueryOk2) {
$results = $stmt->fetchAll(PDO::FETCH_COLUMN) + $stmt2->fetchAll(PDO::FETCH_COLUMN);
} else {
trigger_error('Error executing statement.', E_USER_ERROR);
}
$db = null;
return $results;
}
示例5: query
protected function query($sql, $action)
{
$con = getDbConnection();
$stmt = $con->prepare($sql) or die($con->error);
$result;
$ex;
try {
$result = $action($stmt, $con);
if ($stmt->error !== null && $stmt->error !== "") {
throw new Exception($stmt->error);
}
} catch (Exception $e) {
$ex = $e;
}
$stmt->close();
$con->close();
// try,finally
if (isset($ex)) {
throw $ex;
}
return $result;
}
示例6: getFormItems
//.........这里部分代码省略.........
</div>
</span>
</div>
EOQ2;
}
$out = $out2;
// ------ siteConfig_a.php
$out .= <<<EOQ
</div>
</div>
<div class="floatbox" id="fb6">
<h2>{$mod_strings['LBL_SITECFG_TITLE']}</h2>
<div class="form_section">
<p>{$errors}</p>
<div class="required">{$mod_strings['LBL_REQUIRED']}</div>
<h3>{$mod_strings['LBL_SITECFG_TITLE2']}<div class="tooltip-toggle"><em> i </em><div class="tooltip">{$mod_strings['LBL_SITECFG_PASSWORD_MSG']}</div></div></h3>
EOQ;
//hide this in typical mode
if (!empty($_SESSION['install_type']) && strtolower($_SESSION['install_type']) == 'custom') {
$out .= <<<EOQ
<div class='install_block'>
{$mod_strings['LBL_SITECFG_URL_MSG']}
<span class="required">*</span>
<label><b>{$mod_strings['LBL_SITECFG_URL']}</b></label>
<input type="text" name="setup_site_url" value="{$_SESSION['setup_site_url']}" size="40" />
<br>{$mod_strings['LBL_SITECFG_SYS_NAME_MSG']}
<span class="required">*</span>
<label><b>{$mod_strings['LBL_SYSTEM_NAME']}</b></label>
<input type="text" name="setup_system_name" value="{$_SESSION['setup_system_name']}" size="40" /><br>
</div>
EOQ;
$db = getDbConnection();
if ($db->supports("collation")) {
$collationOptions = $db->getCollationList();
}
if (!empty($collationOptions)) {
if (isset($_SESSION['setup_db_options']['collation'])) {
$default = $_SESSION['setup_db_options']['collation'];
} else {
$default = $db->getDefaultCollation();
}
$options = get_select_options_with_id(array_combine($collationOptions, $collationOptions), $default);
$out .= <<<EOQ
<div class='install_block'>
<br>{$mod_strings['LBL_SITECFG_COLLATION_MSG']}
<span class="required">*</span>
<label><b>{$mod_strings['LBL_COLLATION']}</b></label>
<select name="setup_db_collation" id="setup_db_collation">{$options}</select><br>
</div>
EOQ;
}
}
$help_url = get_help_button_url();
if (!isset($_SESSION['email1'])) {
$_SESSION['email1'] = null;
}
if (!isset($_SESSION['setup_site_admin_user_name'])) {
$_SESSION['setup_site_admin_user_name'] = null;
}
$out .= <<<EOQ
<div class='install_block'>
<!--
<p class="ibmsg">{$mod_strings['LBL_SITECFG_PASSWORD_MSG']}</p>
-->
示例7: session_start
<?php
require_once '../include/function.php';
session_start();
if (isset($_SESSION['id'])) {
if (isset($_SESSION['util']) && isset($_SESSION['clegen'])) {
if ($_SESSION['id'] == $_SESSION['util'] . $_SESSION['clegen']) {
$_SESSION['bienconnecte'] = 1;
if ($_SESSION['bienconnecte'] == 1) {
?>
<div id="contenu">
<h2>Modification d'une image</h2>
<?php
require_once '../include/function.php';
$id = $_GET['id'];
$contenuarticle = getDbConnection()->query("select id, titre, date,commentaire,photo from contenu where id =" . $id);
$contenu = $contenuarticle->fetch();
?>
<form action="../actions/modifierimage.php" method="post" enctype="multipart/form-data">
<p><input type="hidden" name="id" value="<?php
echo $contenu['id'];
?>
" /></p>
<fieldset>
<legend><i>Les champs signalés par * sont obligatoires</i></legend>
* <span>Titre : </span>
<input type="text" name="titre" id="titre" value="<?php
echo $contenu['titre'];
?>
"/></br>
* <span>Lien vers la page : </span>
<select name="commentaire" id="commentaire" size="11">
示例8: processMessage
function processMessage($message)
{
// Variable
$conn = getDbConnection();
//connection to DB
$message_id = $message['message_id'];
$chat_id = $message['chat']['id'];
/*
* Control the empty fields in incoming message
*/
if (isset($message['from']['first_name'])) {
$first_name_id = $message['from']['first_name'];
} else {
$first_name_id = '';
}
if (isset($message['from']['last_name'])) {
$last_name_id = $message['from']['last_name'];
} else {
$last_name_id = '';
}
if (isset($message['from']['username'])) {
$username_id = $message['from']['username'];
} else {
$username_id = '';
}
if (isset($message['text'])) {
/*
* The very function of process messag
*/
$text = $message['text'];
if (strpos($text, "/start") === 0) {
apiRequest("sendMessage", array('chat_id' => $chat_id, "text" => MESSAGE_BENVENUTO, 'reply_markup' => array('keyboard' => array(array('Help', 'Social Media', 'Forum', 'Credit')), 'one_time_keyboard' => false, 'resize_keyboard' => true)));
/*
* Log the user in DB. If the user is already activated only you change their status in active also.
*/
dbLogUserStart($chat_id, $first_name_id, $last_name_id, $username_id);
/*
* Possibility to send logo/image when the user enter for first time (optinal)
* Function: SendPicture($chat_id, INFO_PHOTO );
*/
/*
* Menù Help
*/
} else {
if ($text === "Help") {
apiRequest("sendMessage", array('chat_id' => $chat_id, "text" => MESSAGE_HELP, 'reply_markup' => array('keyboard' => array(array('Info', 'Comandi', 'Contatti', 'Exit')), 'one_time_keyboard' => false, 'resize_keyboard' => true)));
} else {
if ($text === "Info" || $text === "Informazioni" || $text === "/informazioni") {
apiRequest("sendMessage", array('chat_id' => $chat_id, "text" => MESSAGE_INFO, "disable_web_page_preview" => true));
} else {
if ($text === "Comandi") {
apiRequest("sendMessage", array('chat_id' => $chat_id, "text" => MESSAGE_COMANDI, "disable_web_page_preview" => true));
} else {
if ($text === "Contatti") {
apiRequest("sendMessage", array('chat_id' => $chat_id, "text" => MESSAGE_CONTATTI, "disable_web_page_preview" => true));
} else {
if ($text === "Exit") {
/*
* Return to menù home page
*/
apiRequest("sendMessage", array('chat_id' => $chat_id, "text" => 'Sei tornato al menu\' in Home.', 'reply_markup' => array('keyboard' => array(array('Help', 'Social Media', 'Forum', 'Credit')), 'one_time_keyboard' => false, 'force_reply_keyboard' => true, 'resize_keyboard' => true)));
} else {
if ($text === "Social Media") {
apiRequest("sendMessage", array('chat_id' => $chat_id, "text" => MESSAGE_SOCIAL, "disable_web_page_preview" => true));
} else {
if ($text === "Forum") {
apiRequest("sendMessage", array('chat_id' => $chat_id, "text" => MESSAGE_FORUM, "disable_web_page_preview" => true));
} else {
if ($text === "Credit") {
apiRequest("sendMessage", array('chat_id' => $chat_id, "text" => MESSAGE_CREDIT, "disable_web_page_preview" => true));
} else {
if ($text === "/stop") {
/*
* Here inserted disabling user from the DB (not cleared but only put off)
*/
apiRequest("sendMessage", array('chat_id' => $chat_id, "text" => MESSAGE_EXIT));
dbLogUserStop($chat_id);
} else {
if (strpos($text, "Stop") === 0) {
/*
* For ecception
* Here inserted disabling user from the DB (not cleared but only put off)
*/
apiRequest("sendMessage", array('chat_id' => $chat_id, "text" => MESSAGE_EXIT));
dbLogUserStop($chat_id);
} else {
/*
* Function that stores all messages that users send through extra bot
*/
apiRequest("sendMessage", array('chat_id' => $chat_id, "reply_to_message_id" => $message_id, "text" => MESSAGE_NULL));
dbLogTextOn($chat_id, $first_name_id, $message_id, $text);
}
}
}
}
}
}
}
}
}
//.........这里部分代码省略.........
示例9: serveur
echo "Le fichier dépasse la limite autorisée par le serveur (fichier php.ini) !";
break;
case 2:
// UPLOAD_ERR_FORM_SIZE
echo "Le fichier dépasse la limite autorisée dans le formulaire HTML !";
break;
case 3:
// UPLOAD_ERR_PARTIAL
echo "L'envoi du fichier a été interrompu pendant le transfert !";
break;
case 4:
// UPLOAD_ERR_NO_FILE
echo "Le fichier que vous avez envoyé a une taille nulle !";
break;
}
} else {
move_uploaded_file($_FILES['photo']['tmp_name'], "../include/design/photos/" . $_FILES['photo']['name']);
getDbConnection()->query('INSERT INTO contenu (titre,date,commentaire,photo) VALUES (' . "'" . $_POST["titre"] . "'," . "now()" . ",'" . $_POST["commentaire"] . "','" . $_FILES['photo']['name'] . "')");
header("Location: ../admin/admin.php?id=images");
}
} else {
echo "Problème à la connexion <br />";
}
}
}
} else {
print "Votre IP a été enregistré, tentative de Hack détecté.";
}
} else {
print "Impossible d'acédez a la page directement!!";
}
示例10: session_start
<?php
session_start();
require_once '../include/function.php';
if (isset($_POST['user']) && isset($_POST['mdp'])) {
if (getDbConnection()) {
$pw = md5($_POST["mdp"]);
if (getDbConnection()->query('SELECT login,pass_md5 from membre where login= "' . $_POST["user"] . '" and pass_md5 = "' . $pw . '"')->rowcount()) {
$_SESSION['clegen'] = md5(rand());
$_SESSION['util'] = crypt($_POST["user"], '$5$');
$_SESSION['id'] = $_SESSION['util'] . $_SESSION['clegen'];
header('Location: ../admincompudream.php ');
} else {
$_SESSION['id'] = "erreur";
header('Location: ../admincompudream.php');
}
} else {
$_SESSION['id'] = "connexion";
header('Location: ../admincompudream.php');
}
} else {
header('Location: ../compudream.php');
}
示例11: getDbConnection
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/templates/preheader.php";
if (isset($_POST['id'])) {
$link = getDbConnection();
$dbid = $link->query("SELECT user FROM comments WHERE id = " . $_POST['id'])->fetch_array()['user'];
if (isset($userid) && $userid == $dbid) {
$link->query("DELETE FROM comments WHERE id = " . $_POST['id']);
} else {
echo $dbid . "/" . $userid;
}
$link->close();
}
示例12: getDbConnection
<div class="clear"></div>
</div>
</div>
</header>
<div class="main">
<!--==============================Content=================================-->
<div class="content"><div class="ic">More Website Templates @ TemplateMonster.com - December 16, 2013!</div>
<div class="container_12">
<div class="grid_4 ">
<a href="#" class="donate">ωρολογιο προγραμμα</a>
<h4>ολες οι ταξεις</h4>
<ul class="list">
<?php
require_once 'helpers/dbConnectioni.php';
$conn = getDbConnection();
$sql = "SELECT class,lessonprogram_file FROM lessonprogram";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while ($row = $result->fetch_assoc()) {
echo $row['class'] . " " . $row['lessonprogram_file'];
echo '</br>';
}
} else {
echo "0 results";
}
$conn->close();
?>
</ul>
示例13: empty
case 'dbname':
$default = empty($settings[$name]) ? '' : $settings[$name];
break;
}
$value = $default;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$value = empty($_POST[$name]) ? $default : $_POST[$name];
}
$settings[$name] = $value;
}
}
$_SESSION['settings'] = $settings;
// if a POST, try to connect to the database using the parameters
$error = '';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$instance = getDbConnection($error);
if ($instance && empty($error)) {
$_SESSION['settings'] = $settings;
$wizard->redirectToPage('+1');
exit;
}
}
ob_start();
if (!empty($error)) {
echo '<div class="x2-note errorMsg">' . $error . "</div>\n";
}
?>
<fieldset>
<legend><?php
echo LEGEND_CONNECTION;
?>
示例14: getDbConnection
<?php
if (isset($_SESSION['id'])) {
if (isset($_SESSION['util']) && isset($_SESSION['clegen'])) {
if ($_SESSION['id'] == $_SESSION['util'] . $_SESSION['clegen']) {
$_SESSION['bienconnecte'] = 1;
if ($_SESSION['bienconnecte'] == 1) {
$compteur = getDbConnection()->query("select * from contact");
// Récupération et affichage des données
$ligne = $compteur->fetch();
print "<table border='1'><p align='left'><a href='../compudream.php' title='Modifier a partir du site'>Retour a la page d'accueil</a></p><tr><th>Libelle</th><th>Adresse</th><th>Téléphone</th><th>E-mail</th><th>Facebook</th><th>Modifier</th></tr>";
$requetearticle = getDbConnection()->query("SELECT con_id, libelle, adresse1, adresse2, cp, ville, tel,email,facebook FROM contact ORDER BY con_id");
$ligne = $requetearticle->fetch();
// Récupération et affichage des données
while ($ligne) {
print '<td>' . stripslashes($ligne['libelle']) . '</td><td>' . stripslashes($ligne['adresse1']) . ' ' . stripslashes($ligne['adresse2']) . ' ' . stripslashes($ligne['cp']) . ' ' . stripslashes($ligne['ville']) . '</td><td>' . stripslashes($ligne['tel']) . '</td><td>' . stripslashes($ligne['email']) . '</td><td>' . stripslashes($ligne['facebook']) . '</td><td><a href="../forms/modifiercontact.php?id=' . $ligne['con_id'] . '">Modifier</a></td></tr>';
$ligne = $requetearticle->fetch();
}
print "</table>";
}
}
} else {
print "Votre IP a été enregistré, tentative de Hack détecté.";
}
} else {
print "Impossible d'acédez a la page directement!!";
}
示例15: getDbConnection
EOQ;
//hide this in typical mode
if (!empty($_SESSION['install_type']) && strtolower($_SESSION['install_type']) == 'custom') {
$out .= <<<EOQ
<div class='install_block'>
{$mod_strings['LBL_SITECFG_URL_MSG']}
<span class="required">*</span>
<label><b>{$mod_strings['LBL_SITECFG_URL']}</b></label>
<input type="text" name="setup_site_url" id="button_next2" value="{$_SESSION['setup_site_url']}" size="40" />
<br>{$mod_strings['LBL_SITECFG_SYS_NAME_MSG']}
<span class="required">*</span>
<label><b>{$mod_strings['LBL_SYSTEM_NAME']}</b></label>
<input type="text" name="setup_system_name" value="{$_SESSION['setup_system_name']}" size="40" /><br>
</div>
EOQ;
$db = getDbConnection();
if ($db->supports("collation")) {
$collationOptions = $db->getCollationList();
}
if (!empty($collationOptions)) {
if (isset($_SESSION['setup_db_options']['collation'])) {
$default = $_SESSION['setup_db_options']['collation'];
} else {
$default = $db->getDefaultCollation();
}
$options = get_select_options_with_id(array_combine($collationOptions, $collationOptions), $default);
$out .= <<<EOQ
<div class='install_block'>
<br>{$mod_strings['LBL_SITECFG_COLLATION_MSG']}
<span class="required">*</span>
<label><b>{$mod_strings['LBL_COLLATION']}</b></label>