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


PHP DataObject::connect方法代碼示例

本文整理匯總了PHP中DataObject::connect方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataObject::connect方法的具體用法?PHP DataObject::connect怎麽用?PHP DataObject::connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DataObject的用法示例。


在下文中一共展示了DataObject::connect方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: deleteAllForMember

 public static function deleteAllForMember($memberId)
 {
     $conn = parent::connect();
     $sql = "DELETE FROM " . TBL_ACCESS_LOG . " WHERE memberId = :memberId";
     try {
         $st = $conn->prepare($sql);
         $st->bindValue(":memberId", $memberId, PDO::PARAM_INT);
         $st->execute();
         parent::disconnect($conn);
     } catch (PDOException $e) {
         parent::disconnect($conn);
         die("Query failed: " . $e->getMessage());
     }
 }
開發者ID:raynaldmo,項目名稱:php-education,代碼行數:14,代碼來源:LogEntry.class.php

示例2: insert

 public function insert()
 {
     $conn = parent::connect();
     $sql = "INSERT INTO factura (id_pedido, precio) \nVALUES (:id_pedido, :precio);";
     try {
         $st = $conn->prepare($sql);
         $st->bindValue(":id_pedido", $this->data["id_pedido"], PDO::PARAM_INT);
         $st->bindValue(":precio", $this->data["precio"], PDO::PARAM_STR);
         $st->execute();
         parent::disconnect($conn);
     } catch (PDOException $e) {
         parent::disconnect($conn);
         die("Query failed: " . $e->getMessage());
     }
 }
開發者ID:NARTONIC,項目名稱:tuchefacasa,代碼行數:15,代碼來源:Factura.class.php

示例3: getMember

 public static function getMember($id)
 {
     $conn = parent::connect();
     $sql = "SELECT * FROM " . TBL_MEMBERS . " WHERE id = :id";
     try {
         $st = $conn->prepare($sql);
         $st->bindValue(":id", $id, PDO::PARAM_INT);
         $st->execute();
         if ($row = $st->fetch()) {
             return new Member($row);
         }
     } catch (PDOException $e) {
         die("Query failed: " . $e->getMessage());
     }
 }
開發者ID:raynaldmo,項目名稱:php-education,代碼行數:15,代碼來源:exercise2.php

示例4: insert

 public function insert()
 {
     $conn = parent::connect();
     $sql = "INSERT INTO pedido_menu (id_menu, id_pedido, id_decoracion) \nVALUES (:id_menu, :id_pedido, :id_decoracion);";
     try {
         $st = $conn->prepare($sql);
         $st->bindValue(":id_menu", $this->data["id_menu"], PDO::PARAM_INT);
         $st->bindValue(":id_pedido", $this->data["id_pedido"], PDO::PARAM_INT);
         $st->bindValue(":id_decoracion", $this->data["id_decoracion"], PDO::PARAM_INT);
         $st->execute();
         parent::disconnect($conn);
     } catch (PDOException $e) {
         parent::disconnect($conn);
         die("Query failed: " . $e->getMessage());
     }
 }
開發者ID:NARTONIC,項目名稱:tuchefacasa,代碼行數:16,代碼來源:Pedidos_menu.class.php

示例5: getById

 public static function getById($id_decoracion)
 {
     $conn = parent::connect();
     $sql = "SELECT * FROM decoracion  WHERE id_decoracion = :id_decoracion";
     try {
         $st = $conn->prepare($sql);
         $st->bindValue(":id_decoracion", $id_decoracion, PDO::PARAM_INT);
         $st->execute();
         $row = $st->fetch();
         parent::disconnect($conn);
         if ($row) {
             return new Decoracion($row);
         }
     } catch (PDOException $e) {
         parent::disconnect($conn);
         die("Query failed: " . $e->getMessage());
     }
 }
開發者ID:NARTONIC,項目名稱:tuchefacasa,代碼行數:18,代碼來源:Decoracion.class.php

示例6: getPrecio

 public static function getPrecio($id_menu)
 {
     $conn = parent::connect();
     $sql = "SELECT nombre, precio FROM menu  WHERE id_menu = :id_menu";
     try {
         $st = $conn->prepare($sql);
         $st->bindValue(":id_menu", $id_menu, PDO::PARAM_INT);
         $st->execute();
         $row = $st->fetch();
         parent::disconnect($conn);
         if ($row) {
             return new Menu($row);
         }
     } catch (PDOException $e) {
         parent::disconnect($conn);
         die("Query failed: " . $e->getMessage());
     }
 }
開發者ID:NARTONIC,項目名稱:tuchefacasa,代碼行數:18,代碼來源:Menu.class.php

示例7: getById

 public static function getById($id_bebida)
 {
     $conn = parent::connect();
     $sql = "SELECT * FROM bebidas  WHERE id_bebida = :id_bebida";
     try {
         $st = $conn->prepare($sql);
         $st->bindValue(":id_bebida", $id_bebida, PDO::PARAM_STR);
         $st->execute();
         $row = $st->fetch();
         parent::disconnect($conn);
         if ($row) {
             return new Bebida($row);
         }
     } catch (PDOException $e) {
         parent::disconnect($conn);
         die("Query failed: " . $e->getMessage());
     }
 }
開發者ID:NARTONIC,項目名稱:tuchefacasa,代碼行數:18,代碼來源:Bebida.class.php

示例8: insert

 public function insert()
 {
     $conn = parent::connect();
     $sql = "INSERT INTO cliente (email, pass, nombre, apellidos, telefono) \n           VALUES (:email, SHA(:pass), :nombre, :apellidos, :telefono)";
     try {
         $st = $conn->prepare($sql);
         $st->bindValue(":email", $this->data["email"], PDO::PARAM_STR);
         $st->bindValue(":pass", $this->data["pass"], PDO::PARAM_STR);
         $st->bindValue(":nombre", $this->data["nombre"], PDO::PARAM_STR);
         $st->bindValue(":apellidos", $this->data["apellidos"], PDO::PARAM_STR);
         $st->bindValue(":telefono", $this->data["telefono"], PDO::PARAM_STR);
         $st->execute();
         parent::disconnect($conn);
     } catch (PDOException $e) {
         parent::disconnect($conn);
         die("Query failed: " . $e->getMessage());
     }
 }
開發者ID:NARTONIC,項目名稱:tuchefacasa,代碼行數:18,代碼來源:Cliente.class.php

示例9: getBebidas

 public static function getBebidas()
 {
     $conn = parent::connect();
     $sql = "SELECT * FROM tipos_bebidas;";
     try {
         $st = $conn->prepare($sql);
         $st->execute();
         $tipos = array();
         foreach ($st->fetchAll() as $row) {
             $tipos[] = new Tipo($row);
         }
         $row = $st->fetch();
         parent::disconnect($conn);
         return array($tipos);
     } catch (PDOException $e) {
         parent::disconnect($conn);
         die("Query failed: " . $e->getMessage());
     }
 }
開發者ID:NARTONIC,項目名稱:tuchefacasa,代碼行數:19,代碼來源:Tipos.class.php

示例10: getLogEntries

 public static function getLogEntries($memberId)
 {
     $conn = parent::connect();
     $sql = "SELECT * FROM " . TBL_ACCESS_LOG . " WHERE memberId = :memberId ORDER BY lastAccess DESC";
     try {
         $st = $conn->prepare($sql);
         $st->bindValue(":memberId", $memberId, PDO::PARAM_INT);
         $st->execute();
         $logEntries = array();
         foreach ($st->fetchAll() as $row) {
             $logEntries[] = new LogEntry($row);
         }
         parent::disconnect($conn);
         return $logEntries;
     } catch (PDOException $e) {
         parent::disconnect($conn);
         die("Query failed: " . $e->getMessage());
     }
 }
開發者ID:raynaldmo,項目名稱:php-education,代碼行數:19,代碼來源:LogEntry.class.php

示例11: authenticate

 public static function authenticate(array $data)
 {
     $pdo = parent::connect();
     if ($data['email'] != '') {
         $attr = 'email';
     } elseif ($data['username'] != '') {
         $attr = 'username';
     }
     $pass = hash_hmac('SHA256', $data['pass'], User::SALT);
     $table = TBL_USERS;
     $q = "SELECT id, username, userType, email, pass, dateAdded FROM {$table} WHERE {$attr}=:attr AND pass=:pass";
     $stmt = $pdo->prepare($q);
     $stmt->execute(array(':attr' => $data[$attr], ':pass' => $pass));
     $row = $stmt->fetch(PDO::FETCH_ASSOC);
     parent::disconnect($pdo);
     if ($row) {
         return new User($row);
     }
 }
開發者ID:herrder,項目名稱:mybootstrapedcms,代碼行數:19,代碼來源:User.php

示例12: record

 public function record()
 {
     $conn = parent::connect();
     $sql = "SELECT * FROM " . TBL_MESSAGE . " ";
     $sql .= "WHERE member_id = :member_id and message_text = :message_text and subject = :subject";
     try {
         $st = $conn->prepare($sql);
         $st->bindValue(":member_id", $this->data["member_id"], PDO::PARAM_INT);
         $st->bindValue(":message_text", $this->data["message_text"], PDO::PARAM_STR);
         $st->bindValue(":subject", $this->data["subject"], PDO::PARAM_STR);
         $st->execute();
         //  var_dump($sql, $this->data, $st);
         if ($st->fetch()) {
             $sql = "UPDATE " . TBL_MESSAGE . " SET num_access = num_access + 1 ";
             $sql .= "WHERE member_id = :member_id and message_text = :message_text and subject = :subject";
             $st = $conn->prepare($sql);
             $st->bindValue(":member_id", $this->data["member_id"], PDO::PARAM_INT);
             $st->bindValue(":message_text", $this->data["message_text"], PDO::PARAM_STR);
             $st->bindValue(":subject", $this->data["subject"], PDO::PARAM_STR);
             //  var_dump($sql, $st);
             $st->execute();
         } else {
             $sql = "INSERT INTO " . TBL_MESSAGE . " ( member_id, message_text, num_access, subject ) ";
             $sql .= " VALUES ( :member_id, :message_text, 1, :subject )";
             $st = $conn->prepare($sql);
             $st->bindValue(":member_id", $this->data["member_id"], PDO::PARAM_INT);
             $st->bindValue(":message_text", $this->data["message_text"], PDO::PARAM_STR);
             $st->bindValue(":subject", $this->data["subject"], PDO::PARAM_STR);
             //  var_dump($sql, $st);
             $st->execute();
         }
         //  var_dump($sql, $st);
         parent::disconnect($conn);
     } catch (PDOException $e) {
         parent::disconnect($conn);
         die("Query failed: " . $e->getMessage());
     }
 }
開發者ID:hoiwanjohnlouis,項目名稱:eclipsePrototyping,代碼行數:38,代碼來源:Message.class.php

示例13: getTravelAdvisories

 public function getTravelAdvisories()
 {
     $connection = parent::connect();
     $selectSQL = "SELECT * FROM TRAVELADVISORY";
     $rows = $connection->query($selectSQL);
     $traveladvisories = array();
     foreach ($rows as $row) {
         $traveladvisory = new traveladvisory();
         $traveladvisory->setTravelAdvisoryId($row[0]);
         $traveladvisory->setTravelAdvisorySourceName($row[1]);
         $traveladvisory->setTravelAdvisorySourceLink($row[2]);
         $traveladvisory->setTravelAdvisorySourceLinkType($row[3]);
         $traveladvisories[] = $traveladvisory;
     }
     parent::disconnect($connection);
     return $traveladvisories;
 }
開發者ID:bhagvank,項目名稱:nuntium,代碼行數:17,代碼來源:TravelAdvisoryPDO.php

示例14: insert

 public function insert()
 {
     $conn = parent::connect();
     $sql = "INSERT INTO pedidos (id_cliente, fecha, hora, cp, direccion, comensales) \nVALUES (:id_cliente, STR_TO_DATE(:fecha,'%d/%m/%Y'), :hora, :cp, :direccion, :comensales);";
     try {
         $st = $conn->prepare($sql);
         $st->bindValue(":id_cliente", $this->data["id_cliente"], PDO::PARAM_INT);
         $st->bindValue(":fecha", $this->data["fecha"], PDO::PARAM_STR);
         $st->bindValue(":hora", $this->data["hora"], PDO::PARAM_STR);
         $st->bindValue(":cp", $this->data["cp"], PDO::PARAM_INT);
         $st->bindValue(":direccion", $this->data["direccion"], PDO::PARAM_STR);
         $st->bindValue(":comensales", $this->data["comensales"], PDO::PARAM_INT);
         $st->execute();
         parent::disconnect($conn);
     } catch (PDOException $e) {
         parent::disconnect($conn);
         die("Query failed: " . $e->getMessage());
     }
 }
開發者ID:NARTONIC,項目名稱:tuchefacasa,代碼行數:19,代碼來源:Pedidos.class.php

示例15: getEvents

 public function getEvents()
 {
     $connection = parent::connect();
     $selectSQL = "SELECT * FROM EVENT";
     $rows = $connection->query($selectSQL);
     $events = array();
     foreach ($rows as $row) {
         $event = new Event();
         $event->setEventId($row[0]);
         $event->setEventType($row[1]);
         $event->setEventSourceName($row[2]);
         $event->setEventSourceLink($row[3]);
         $event->setEventSourceLinkType($row[4]);
         $events[] = $event;
     }
     parent::disconnect($connection);
     return $events;
 }
開發者ID:bhagvank,項目名稱:nuntium,代碼行數:18,代碼來源:EventPDO.php


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