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


PHP unknown_type::lastInsertId方法代碼示例

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


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

示例1: insert

 public function insert(array $array = array())
 {
     if (!empty($array)) {
         $this->inject($array);
     }
     $columns = $this->queryColumns();
     $cols = array();
     $vals = array();
     $params = array();
     foreach ($columns as $c) {
         if (array_key_exists($c, $this->data)) {
             $cols[] = $c;
             $vals[] = ':' . $c;
             $params[':' . $c] = $this->data[$c];
         }
     }
     if (in_array('created_on', $columns) && !in_array('created_on', $cols)) {
         $cols[] = 'created_on';
         $vals[] = ':created_on';
         $params[':created_on'] = date('Y-m-d H:i:s');
     }
     $sql = "INSERT INTO " . static::$table . ' (' . implode(', ', $cols) . ') ' . 'VALUES (' . implode(', ', $vals) . ')';
     $s = $this->db->prepare($sql);
     $check = $s->execute($params);
     $this->{static::$primary} = $this->db->lastInsertId(static::$sequence);
     return $check;
 }
開發者ID:wamania,項目名稱:mynd-framework,代碼行數:27,代碼來源:Model.php

示例2: addSite

 /**
  * Add a site.. but take care! This works with regex!!!
  * @param unknown_type $name
  * @param unknown_type $connection
  */
 public function addSite($name, $connection)
 {
     if ($connection->exec("INSERT INTO `learncards`.`config_loginneedlesssites` (`site`) VALUES ('" . $name . "');") > 0) {
         $site = new allowedSite();
         $site->setName($name);
         $site->setId($connection->lastInsertId());
         array_push($this->allAllowedSites, $site);
         return "Site " . $name . " is successfully added";
     } else {
         return "A error happend. Nothings changed!";
     }
 }
開發者ID:hersche,項目名稱:Peta,代碼行數:17,代碼來源:base.php

示例3: GetInsertID

 /**
  * (non-PHPdoc)
  * @see RedBean/RedBean_Driver#GetInsertID()
  */
 public function GetInsertID()
 {
     return (int) $this->pdo->lastInsertId();
 }
開發者ID:nurulimamnotes,項目名稱:DewiSriDesktop,代碼行數:8,代碼來源:PDO.php

示例4: newQuestion

 /**
  * Create a new question
  * @param question $question
  * @param unknown_type $connection
  */
 public function newQuestion($question, $connection)
 {
     $connection->exec("INSERT INTO `" . $GLOBALS['dbPrefix'] . "question_question` (`set`, `question`, `mode`) VALUES (" . $this->setid . ", '" . $question->getQuestion() . "', '" . $question->getMode() . "')");
     $question->setId($connection->lastInsertId());
     array_push($this->questions, $question);
 }
開發者ID:hersche,項目名稱:Peta,代碼行數:11,代碼來源:card.class.php

示例5: GetInsertID

 /**
  * (non-PHPdoc)
  * @see RedBean/RedBean_Driver#GetInsertID()
  */
 public function GetInsertID()
 {
     $this->connect();
     return (int) $this->pdo->lastInsertId();
 }
開發者ID:nev3rm0re,項目名稱:hondex,代碼行數:9,代碼來源:rb127lg.php


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