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


PHP Db::prepare方法代碼示例

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


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

示例1: ejecutar

 /**
  * Función para ejecutar consultar de tipo INSERT, UPDATE, DELETE
  * @param array $parametros
  * @param string $sql
  */
 protected function ejecutar($parametros, $sql = null)
 {
     if ($sql == null) {
         $sql = $this->sql;
     }
     $sentencia = $this->db->prepare($sql);
     if (!$sentencia->execute($parametros)) {
         self::enviarError($this->db->errorInfo());
     }
 }
開發者ID:josegaitan123,項目名稱:colegio,代碼行數:15,代碼來源:Modelo.php

示例2: evolve

 public function evolve($buildingId)
 {
     $buildingCost = $this->db->prepare("SELECT\n            lvl.food,\n            lvl.gold\n        FROM\n          userbuildings ub\n        INNER JOIN\n          buildinglvldefs lvl ON ub.level_id + 1 = lvl.id\n        WHERE\n          ub.id = ?");
     $buildingCost->execute([$buildingId]);
     $buildingCost = $buildingCost->fetch();
     if ($this->user->getGold() < $buildingCost['gold'] || $this->user->getFood() < $buildingCost['food']) {
         throw new \Exception("Not enough resources.");
     }
     if (!$this->lvlCompare($buildingId)) {
         throw new \Exception('Max level reached.');
     }
     $this->user->setGold($this->user->getGold() - $buildingCost['gold']);
     $this->user->setFood($this->user->getFood() - $buildingCost['food']);
     $update = $this->db->prepare("UPDATE\n          userbuildings\n        SET\n          level_id = level_id + 1\n        WHERE\n          user_id = ?\n        AND\n          id = ?");
     $update->execute([$_SESSION["user_id"], $buildingId]);
 }
開發者ID:uFreezy,項目名稱:SoftUni-Web-Development,代碼行數:16,代碼來源:BuildingsRepo.php

示例3: getMe

 /**
  * @todo: store user token from request globally in config object, use username / token to find user and so on
  * @todo: logic must be in Usermodel, move later
  * @returns models\User
  */
 public function getMe()
 {
     $oDb = Db::getInstance();
     $oUser = new models\User();
     $aUser = $oDb->getArray(Db::prepare("SELECT * FROM %s;", [$oUser->getTableName()]));
     return array_shift($aUser);
 }
開發者ID:mroswald,項目名稱:invme,代碼行數:12,代碼來源:Config.php

示例4: tambahKategori

 function tambahKategori($nmkategori)
 {
     $db = new Db();
     $stmt = $db->prepare("INSERT INTO kategori (nmkategori) VALUES (?)");
     $stmt->bindParam(1, $nmkategori);
     $stmt->execute();
     echo "Data Kategori berhasil di simpan";
 }
開發者ID:suregy,項目名稱:uas-web-service,代碼行數:8,代碼來源:Kategori.php

示例5: get_static_modifiers

 public static function get_static_modifiers($user_id)
 {
     $sql = "SELECT * FROM modifiers WHERE user_id = :user_id";
     $req = Db::prepare($sql);
     $req->bindParam(':user_id', $user_id, PDO::PARAM_INT);
     $req->execute();
     return $res = $req->fetch(PDO::FETCH_ASSOC);
 }
開發者ID:ADcreatif,項目名稱:wardieval,代碼行數:8,代碼來源:Cards.class.php

示例6: tambahKategori

 function tambahKategori($cat_name)
 {
     $db = new Db();
     $stmt = $db->prepare("INSERT INTO part_cat (cat_name) VALUES (?)");
     $stmt->bindParam(1, $cat_name);
     $stmt->execute();
     echo "Data Kategori berhasil di simpan";
 }
開發者ID:icecubon,項目名稱:uas-web-services,代碼行數:8,代碼來源:Kategori.php

示例7: tampilLaptop

 function tampilLaptop($brand, $model, $thn_keluar)
 {
     $db = new Db();
     $stmt = $db->prepare("SELECT * FROM laptop");
     $stmt->bindParam(1, $brand);
     $stmt->bindParam(2, $model);
     $stmt->bindParam(3, $thn_keluar);
     $stmt->execute();
 }
開發者ID:irdhirs,項目名稱:uas-web-service,代碼行數:9,代碼來源:Laptop.php

示例8: tampilLaptop

 function tampilLaptop($brand, $model, $release)
 {
     $db = new Db();
     $stmt = $db->prepare("SELECT * FROM laptops");
     $stmt->bindParam(1, $brand);
     $stmt->bindParam(2, $model);
     $stmt->bindParam(3, $release);
     $stmt->execute();
     echo "";
 }
開發者ID:icecubon,項目名稱:uas-web-services,代碼行數:10,代碼來源:Laptop.php

示例9: tambahProduk

 function tambahProduk($brand, $model, $release_year)
 {
     $db = new Db();
     $stmt = $db->prepare("INSERT INTO komputer (brand, model, release_year) VALUES (?, ?, ?)");
     $stmt->bindParam(1, $brand);
     $stmt->bindParam(2, $model);
     $stmt->bindParam(3, $release_year);
     $stmt->execute();
     echo "Sukses";
 }
開發者ID:ezys15,項目名稱:uas-web-service,代碼行數:10,代碼來源:produk.php

示例10: tambahLaptop

 function tambahLaptop($brand, $model, $thn_keluar)
 {
     $db = new Db();
     $stmt = $db->prepare("INSERT INTO laptop (brand, model, thn_keluar) VALUES (?, ?, ?)");
     $stmt->bindParam(1, $brand);
     $stmt->bindParam(2, $model);
     $stmt->bindParam(3, $thn_keluar);
     $stmt->execute();
     echo "Data Laptop berhasi di simpan";
 }
開發者ID:suregy,項目名稱:uas-web-service,代碼行數:10,代碼來源:Laptop.php

示例11: tambahSukuCadang

 function tambahSukuCadang($id_laptop, $id_cat, $part_number, $description)
 {
     $db = new Db();
     $stmt = $db->prepare("INSERT INTO sukucadang (id_laptop,id_cat,part_number,description) VALUES (?, ?, ?, ?)");
     $stmt->bindParam(1, $id_laptop);
     $stmt->bindParam(2, $id_cat);
     $stmt->bindParam(3, $part_number);
     $stmt->bindParam(4, $description);
     $stmt->execute();
     echo "Data Suku Cadang berhasil di simpan";
 }
開發者ID:icecubon,項目名稱:uas-web-services,代碼行數:11,代碼來源:SukuCadang.php

示例12: tambahSukuCadang

 function tambahSukuCadang($laptop_id, $kategori_id, $no_sukucadang, $keterangan)
 {
     $db = new Db();
     $stmt = $db->prepare("INSERT INTO sukucadang (laptop_id,kategori_id,no_sukucadang,keterangan) VALUES (?, ?, ?, ?)");
     $stmt->bindParam(1, $laptop_id);
     $stmt->bindParam(2, $kategori_id);
     $stmt->bindParam(3, $no_sukucadang);
     $stmt->bindParam(4, $keterangan);
     $stmt->execute();
     echo "Data Suku Cadang berhasil di simpan";
 }
開發者ID:suregy,項目名稱:uas-web-service,代碼行數:11,代碼來源:SukuCadang.php

示例13: add

 public function add()
 {
     $fields = $this->format_request();
     $sql = "INSERT troops SET {$fields['sql_params']}\n                ON DUPLICATE KEY UPDATE quantity = quantity + :quantity";
     $req = Db::prepare($sql);
     foreach ($fields['bind_params'] as $field) {
         $req->bindParam($field['name'], $field['value'], $field['type']);
     }
     if ($req->execute()) {
         return Db::getLastInsertId();
     }
     return false;
 }
開發者ID:ADcreatif,項目名稱:wardieval,代碼行數:13,代碼來源:Troop.php

示例14: testInsertWithPreparedStatement

 public function testInsertWithPreparedStatement()
 {
     $this->checkIfFooIsEmpty();
     $o_stmt = $this->db->prepare("INSERT INTO foo (id, comment) VALUES (?, ?)");
     $o_stmt->execute(array(1, 'bar'));
     $qr_select = $this->db->query("SELECT * FROM foo");
     $this->assertInternalType('object', $qr_select);
     $this->assertTrue($qr_select->nextRow());
     $this->assertEquals(1, $qr_select->get('id'));
     $this->assertEquals('bar', $qr_select->get('comment'));
     $this->db->query("DELETE FROM foo");
     $this->checkIfFooIsEmpty();
 }
開發者ID:idiscussforum,項目名稱:providence,代碼行數:13,代碼來源:DbTest.php

示例15: destroy

 public function destroy($id)
 {
     //remove session record from the database and return result
     $res = $this->db->prepare("DELETE FROM {$this->table} WHERE id = :session_id");
     $res->execute(array(':session_id' => $id, ':data' => $data));
     if ($res->rowCount()) {
         return true;
     }
 }
開發者ID:4Publish,項目名稱:4p_core,代碼行數:9,代碼來源:Session.php


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