本文整理汇总了PHP中DbConn::getConn方法的典型用法代码示例。如果您正苦于以下问题:PHP DbConn::getConn方法的具体用法?PHP DbConn::getConn怎么用?PHP DbConn::getConn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbConn
的用法示例。
在下文中一共展示了DbConn::getConn方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insert
public function insert()
{
$pdo = DbConn::getConn();
$pdo->exec("SET NAMES 'utf8';");
$q = "INSERT INTO flowers(cat_id,name,description,image) VALUES (:cat_id,:name,:desc,:img)";
$stmt = $pdo->prepare($q);
$stmt->execute(array(":cat_id" => $this->cat_id, ":name" => $this->name, ":desc" => $this->description, ":img" => $this->image));
}
示例2: get
public static function get($id)
{
$pdo = DbConn::getConn();
$pdo->exec("SET NAMES 'utf8';");
$id = strip_tags(trim($id));
$q = "SELECT * FROM " . static::$table . " WHERE " . static::$key . "=:id";
$stmt = $pdo->prepare($q);
$stmt->bindParam(":id", $id);
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_CLASS, get_called_class());
$res = $stmt->fetch();
return $res;
}
示例3: DbConn
<?php
/*
php test file -- connects to xampp db names sousms, user root, pw ""
*/
include "DbConn.class.php";
try {
// connect to the database -- needed by the classes
// that implement the behaviors
$conn = new DbConn("localhost", "sousms", "root", "");
} catch (Exception $e) {
// add another element
echo "Exception: " . $conn->getDebug() . "<br />" . "\n";
}
// echo "No Exception: " . $conn->getDebug() . "<br />". "\n";
$myConn = $conn->getConn();
$dtb = new DateTime(null, new DateTimeZone("America/Los_Angeles"));
$dte = new DateTime(null, new DateTimeZone("America/Los_Angeles"));
$dte->modify("+10 minutes");
echo "\$dte->format() " . $dte->format("Y-m-d H:i:s") . "\n";
$stmt = $myConn->prepare("insert Login values (1, md5('password'), ?, ?)");
$stmt->execute(array($dtb->format("Y-m-d H:i:s"), $dte->format("Y-m-d H:i:s")));
示例4: DbConn
<?php
//DataFeed Team
//Author: Shaun Wolff
//Script for retrieving feed, parsing the feed, Inserting data into Table for 40 stocks.
include '../service/DbConn.class.php';
$newPDO = new DbConn();
$conn = $newPDO->getConn();
$query = $conn->prepare('CALL enterTickerDataForSymbol(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)');
date_default_timezone_set('America/Los_Angeles');
if (date('Hi') > 355 && date('Hi') < 1705) {
$tradingTime = true;
} else {
$tradingTime = false;
echo "Trading day over.\n";
}
while (file_exists('feedControl') && $tradingTime) {
$url = "https://basicapp.nasdaqomx.com/BasicDataXML/getBasicData?symbolsCsvList=AAPL,ADBE,ADSK,ALU,AMZN,ATVI,AXP,CAKE,CMCSA,COKE";
$xml = simplexml_load_file($url);
foreach ($xml->dataItems as $dataItems) {
$symbol = $dataItems->symbol;
$bestAskPrice = $dataItems->bestAskPrice;
$bestAskQty = $dataItems->bestAskQty;
$bestBidPrice = $dataItems->bestBidPrice;
$bestBidQty = $dataItems->bestBidQty;
$close = $dataItems->close;
$high = $dataItems->high;
$date = $dataItems->date;
$tTime = $dataItems->time;
$tMs = preg_split('/\\./', $tTime);
$time = $tMs[0];
示例5: switch
// add an element to the statusdesc array
$msg->statusdesc[] = "Validation Failure: " . $e->getMessage();
// add another element
$msg->statusdesc[] = $myConn->getDebug();
}
switch ($req->behavior) {
case "getTokenFromCredentials":
// the constructor for Credentials can do some basic validation
// (or throw an exception)
$credentials = new Credentials($req->credentials->username, $req->credentials->password);
$token = null;
$expires = null;
// the validate() method returns true if valid or false
// token, expires, and msg->statusdesc are all passed
// by reference and set inside validate()
if (!$credentials->validate($myConn->getConn(), $token, $expires, $msg->statusdesc)) {
// captures the reason for failure
$msg->statuscode = 1;
// failed
} else {
// success
// set values in the return message
$msg->success = true;
$msg->statuscode = 0;
$msg->statusdesc = "Login successful";
// put the token and expires time in the return message
$msg->retval = array("token" => $token, "expires" => $expires);
}
break;
case "passwordRecovery":
$passwordRecover = new PasswordRecover($req->passwordRecover->username, $req->passwordRecover->password);
示例6: exit
exit("<h1>HTTP Error 400 - Bad Request</h1>\nUnknown behavior: "" . htmlentities($req->behavior) . "".");
} else {
$b = $req->behavior;
$msg = new WebServiceMsg();
$msg->behavior = $b;
$msg->success = false;
$msg->statuscode = 0;
$msg->statusdesc = array();
$msg->retval = null;
$userID = -1;
try {
//Begin validation of parameters
$myConn = new DbConn();
//should now pull database info from config...
//$v = new ParameterValidator($myConn->getConn()); //uncomment for production server
$v = new ParameterValidator($myConn->getConn(), true);
//uncomment for development
//does requested behavior require "token" param?
if (in_array("token", $behaviors[$b])) {
if ($v->isValid("token", $req->token)) {
$userID = $v->getTranslatedValue();
} else {
$msg->statuscode = 1;
}
$msg->statusdesc[] = $v->getMessage();
}
//does requested behavior require "symbol" param?
if (in_array("symbol", $behaviors[$b])) {
if ($v->isValid("symbol", $req->symbol)) {
$symID = $v->getTranslatedValue();
} else {