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


PHP Database::lastInsertId方法代碼示例

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


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

示例1: update

 public function update()
 {
     $inTransaction = Database::inTransaction();
     if (!$inTransaction) {
         Database::beginTransaction();
     }
     $statement = Database::prepare("UPDATE user_power SET `uid`=:uid WHERE id=:id");
     $statement->bindValue(':uid', $this->uid, \PDO::PARAM_INT);
     $statement->bindValue(':id', $this->id, \PDO::PARAM_INT);
     $statement->execute();
     $this->uid = Database::lastInsertId();
     $statement->execute();
     if (!$inTransaction) {
         Database::commit();
     }
 }
開發者ID:haitao-wang,項目名稱:shadowsocks-panel,代碼行數:16,代碼來源:UserPower.php

示例2: insertToDB

 /**
  * Insert current user into database
  * @return int Auto-generated UserID for this user
  */
 public function insertToDB()
 {
     $inTransaction = Database::inTransaction();
     if (!$inTransaction) {
         Database::beginTransaction();
     }
     $statement = Database::prepare("INSERT INTO member SET email=:email, `password`=:pwd, nickname=:nickname");
     $statement->bindValue(':email', $this->email, \PDO::PARAM_STR);
     $statement->bindValue(':pwd', $this->password, \PDO::PARAM_STR);
     $statement->bindValue(':nickname', $this->nickname, \PDO::PARAM_STR);
     $statement->execute();
     $this->id = Database::lastInsertId();
     if (!$inTransaction) {
         Database::commit();
     }
     return $this->id;
 }
開發者ID:biaoiaoo,項目名稱:KK-Framework,代碼行數:21,代碼來源:User.php

示例3: insertToDB

 /**
  * Insert current user into database
  * @return int Auto-generated UserID for this user
  */
 public function insertToDB()
 {
     $inTransaction = Database::inTransaction();
     if (!$inTransaction) {
         Database::beginTransaction();
     }
     $statement = Database::prepare("INSERT INTO member SET email=:email, `password`=:pwd, sspwd=:sspwd, `port`=:port, nickname=:nickname,\n            `flow_up`=:flow_up, `flow_down`=:flow_down, transfer=:transfer, plan=:plan, `enable`=:enable, invite=:invite, regDateLine=:regDateLine");
     $statement->bindValue(':email', $this->email, \PDO::PARAM_STR);
     $statement->bindValue(':pwd', $this->password, \PDO::PARAM_STR);
     $statement->bindValue(':sspwd', $this->sspwd, \PDO::PARAM_STR);
     $statement->bindValue(':port', $this->port, \PDO::PARAM_INT);
     $statement->bindValue(':nickname', $this->nickname, \PDO::PARAM_STR);
     $statement->bindValue(':flow_up', $this->flow_up, \PDO::PARAM_INT);
     $statement->bindValue(':flow_down', $this->flow_down, \PDO::PARAM_INT);
     $statement->bindValue(':transfer', $this->transfer, \PDO::PARAM_INT);
     $statement->bindValue(':plan', $this->plan, \PDO::PARAM_STR);
     $statement->bindValue(':enable', $this->enable, \PDO::PARAM_INT);
     $statement->bindValue(':invite', $this->invite, \PDO::PARAM_INT);
     $statement->bindValue(':regDateLine', $this->regDateLine, \PDO::PARAM_INT);
     $statement->execute();
     $this->uid = Database::lastInsertId();
     if (!$inTransaction) {
         Database::commit();
     }
     return $this->uid;
 }
開發者ID:gclove,項目名稱:shadowsocks-panel,代碼行數:30,代碼來源:User.php

示例4: insertToDB

 /**
  * 增加 Node
  * @param node Id
  */
 public function insertToDB()
 {
     $statement = null;
     $inTransaction = Database::inTransaction();
     if (!$inTransaction) {
         Database::beginTransaction();
     }
     $statement = Database::prepare("INSERT INTO node SET `name`=:name, `type`=:type,\n\t\t\t`server`=:server, `method`=:method, `info`=:info, `status`:=status, `order`=:order");
     $statement->bindValue(':name', $this->name, \PDO::PARAM_STR);
     $statement->bindValue(':type', $this->type, \PDO::PARAM_INT);
     $statement->bindValue(':server', $this->server, \PDO::PARAM_STR);
     $statement->bindValue(':method', $this->method, \PDO::PARAM_STR);
     $statement->bindValue(':info', $this->info, \PDO::PARAM_STR);
     $statement->bindValue(':status', $this->status, \PDO::PARAM_STR);
     $statement->bindValue(':order', $this->order, \PDO::PARAM_INT);
     $statement->execute();
     $this->id = Database::lastInsertId();
     if (!$inTransaction) {
         Database::commit();
     }
     return $this->id;
 }
開發者ID:haitao-wang,項目名稱:shadowsocks-panel,代碼行數:26,代碼來源:Node.php

示例5: insertToDB

 /**
  * Add message
  * @return string
  */
 public function insertToDB()
 {
     $statement = null;
     $inTransaction = Database::inTransaction();
     if (!$inTransaction) {
         Database::beginTransaction();
     }
     $statement = Database::prepare("INSERT INTO message SET `content`=:content, `pushTime`=:pushTime,\n\t\t\t`addTime`=:addTime, `pushUsers`=:pushUsers, `type`=:type, `pushEndTime`=:pushEndTime, `order`=:order");
     $statement->bindValue(':content', $this->content, \PDO::PARAM_STR);
     $statement->bindValue(':pushTime', $this->pushTime, \PDO::PARAM_INT);
     $statement->bindValue(':addTime', $this->addTime, \PDO::PARAM_INT);
     $statement->bindValue(':pushUsers', $this->pushUsers, \PDO::PARAM_STR);
     $statement->bindValue(':type', $this->type, \PDO::PARAM_INT);
     $statement->bindValue(':pushEndTime', $this->pushEndTime, \PDO::PARAM_INT);
     $statement->bindValue(':order', $this->order, \PDO::PARAM_INT);
     $statement->execute();
     $this->id = Database::lastInsertId();
     if (!$inTransaction) {
         Database::commit();
     }
     return $this->id;
 }
開發者ID:gclove,項目名稱:shadowsocks-panel,代碼行數:26,代碼來源:Message.php


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