當前位置: 首頁>>代碼示例>>PHP>>正文


PHP MySql::getConnection方法代碼示例

本文整理匯總了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'];
 }
開發者ID:brianmpollack,項目名稱:PHP-Equation-Evaluator,代碼行數:16,代碼來源:operand.php

示例2: testGetInvalidConnection

 /**
  * @expectedException \MiniOrm\DbalException
  */
 public function testGetInvalidConnection()
 {
     $oConfig = Configuration::getInstance();
     $oConfig->read(__DIR__ . self::TEST_EMPTY_CONFIG);
     $this->object->getConnection($oConfig);
 }
開發者ID:Beanbiscuit,項目名稱:examples,代碼行數:9,代碼來源:SqliteTest.php

示例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>
開發者ID:brianmpollack,項目名稱:EECS-341-Final-Project,代碼行數:31,代碼來源:makeSale.php


注:本文中的MySql::getConnection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。