本文整理匯總了PHP中MySql::getConnection方法的典型用法代碼示例。如果您正苦於以下問題:PHP MySql::getConnection方法的具體用法?PHP MySql::getConnection怎麽用?PHP MySql::getConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MySql
的用法示例。
在下文中一共展示了MySql::getConnection方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getValue
public function getValue()
{
require "mysql_util.php";
if (isset($operandValue)) {
return $operandValue;
}
$mysqli = MySql::getConnection();
$questionID = trim($operandString, "[]");
$mysql_value = $mysqli->query("SELECT `Response` FROM Questions WHERE `ID` = '{$questionID}'");
if (!$mysql_value) {
throw new Exception("There was a MySQL error: {$mysqli->error}");
return false;
}
$mysql_value = mysqli_fetch_assoc($mysql_value);
return $mysql_value['Response'];
}
示例2: testGetInvalidConnection
/**
* @expectedException \MiniOrm\DbalException
*/
public function testGetInvalidConnection()
{
$oConfig = Configuration::getInstance();
$oConfig->read(__DIR__ . self::TEST_EMPTY_CONFIG);
$this->object->getConnection($oConfig);
}
示例3: foreach
<?php
require "mysql.php";
$mysqli = MySql::getConnection();
$user_message = "";
if (isset($_POST['submit'])) {
$customerID = $_POST['customer'];
$itemsSold = $_POST['item'];
$quantitySold = $_POST['quantity'];
$sql = "";
foreach ($itemsSold as $key => $itemNumber) {
$quantity = $quantitySold[$key];
$sql .= "INSERT INTO Sales (`CustomerID`, `ItemNumber`, `Quantity`, `Date`) VALUES ('{$customerID}', '{$itemNumber}', '{$quantity}', now());";
}
if ($sql != "") {
$sale = $mysqli->multi_query($sql);
if (!$sale) {
trigger_error("Could not save the sale. Error: {$mysqli->error}");
} else {
$user_message = "Thank you. Your sale has been recorded.";
do {
$mysqli->use_result();
} while ($mysqli->next_result());
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>