当前位置: 首页>>代码示例>>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;未经允许,请勿转载。