Пример #1
0
 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
0
 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
0
<?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
0
<?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
0
     // 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
0
     exit("<h1>HTTP Error 400 - Bad Request</h1>\nUnknown behavior: &quot;" . htmlentities($req->behavior) . "&quot;.");
 } 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 {