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


PHP mysqli_stmt::prepare方法代碼示例

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


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

示例1: salvaAdmin

 /**
  * Rende persistenti le modifiche all'anagrafica di un admin sul db
  * @param Admin $a l'admin considerato
  * @param mysqli_stmt $stmt un prepared statement
  * @return int il numero di righe modificate
  */
 private function salvaAdmin(Admin $a, mysqli_stmt $stmt)
 {
     $query = " update admins set \n                    password = ?,\n                    nome = ?,\n                    cognome = ?,\n                    email = ?,\n                    where admins.id = ?\n                    ";
     $stmt->prepare($query);
     if (!$stmt) {
         error_log("[salvaAdmin] impossibile" . " inizializzare il prepared statement");
         return 0;
     }
     if (!$stmt->bind_param('ssssi', $a->getPassword(), $a->getNome(), $a->getCognome(), $a->getEmail(), $a->getId())) {
         error_log("[salvaAdmin] impossibile" . " effettuare il binding in input");
         return 0;
     }
     if (!$stmt->execute()) {
         error_log("[caricaRegistrati] impossibile" . " eseguire lo statement");
         return 0;
     }
     return $stmt->affected_rows;
 }
開發者ID:Artorias91,項目名稱:Progetto-AMM,代碼行數:24,代碼來源:UserFactory.php

示例2: salvaDocente

 /**
  * Rende persistenti le modifiche all'anagrafica di un docente sul db
  * @param Docente $d il docente considerato
  * @param mysqli_stmt $stmt un prepared statement
  * @return int il numero di righe modificate
  */
 private function salvaDocente(Docente $d, mysqli_stmt $stmt)
 {
     $query = " update docenti set \n                    password = ?,\n                    nome = ?,\n                    cognome = ?,\n                    email = ?,\n                    citta = ?,\n                    provincia = ?,\n                    cap = ?,\n                    via = ?,\n                    ricevimento = ?,\n                    numero_civico = ?,\n                    dipartimento_id = ?\n                    where docenti.id = ?\n                    ";
     $stmt->prepare($query);
     if (!$stmt) {
         error_log("[salvaStudente] impossibile" . " inizializzare il prepared statement");
         return 0;
     }
     if (!$stmt->bind_param('sssssssssiii', $d->getPassword(), $d->getNome(), $d->getCognome(), $d->getEmail(), $d->getCitta(), $d->getProvincia(), $d->getCap(), $d->getVia(), $d->getRicevimento(), $d->getNumeroCivico(), $d->getDipartimento()->getId(), $d->getId())) {
         error_log("[salvaStudente] impossibile" . " effettuare il binding in input");
         return 0;
     }
     if (!$stmt->execute()) {
         error_log("[caricaIscritti] impossibile" . " eseguire lo statement");
         return 0;
     }
     return $stmt->affected_rows;
 }
開發者ID:nadiajolanda,項目名稱:esAMM2014,代碼行數:24,代碼來源:UserFactory.php

示例3: salvaAdmin

 /**
  * Rende persistenti le modifiche all'anagrafica di un docente sul db
  * @param Admin $d il docente considerato
  * @param mysqli_stmt $stmt un prepared statement
  * @return int il numero di righe modificate
  */
 private function salvaAdmin(admin $d, mysqli_stmt $stmt)
 {
     $query = " update admin set \n                    password = ?,\n                    nome = ?,\n                    cognome = ?,\n                    via = ?,\n                    civico = ?,\n                    citta = ?,\n                    cap = ?,\n                    telefono = ?,\n                    where admin.id = ?\n                    ";
     $stmt->prepare($query);
     if (!$stmt) {
         error_log("[salvaCliente] impossibile" . " inizializzare il prepared statement");
         return 0;
     }
     if (!$stmt->bind_param('ssssissii', $d->getPassword(), $d->getNome(), $d->getCognome(), $d->getVia(), $d->getCivico(), $d->getCitta(), $d->getCap(), $d->getTelefono(), $d->getId())) {
         error_log("[salvaCliente] impossibile" . " effettuare il binding in input");
         return 0;
     }
     if (!$stmt->execute()) {
         error_log("[caricaIscritti] impossibile" . " eseguire lo statement");
         return 0;
     }
     return $stmt->affected_rows;
 }
開發者ID:headlessdoll,項目名稱:Amm2015,代碼行數:24,代碼來源:UserFactory.php

示例4: prepare

 /**
  * Prepare an SQL statement for execution
  *
  * @link  http://php.net/manual/en/mysqli-stmt.prepare.php
  *
  * @param string $query <p>
  *                      The query, as a string. It must consist of a single SQL statement.
  *                      </p>
  *                      <p>
  *                      You can include one or more parameter markers in the SQL statement by
  *                      embedding question mark (?) characters at the
  *                      appropriate positions.
  *                      </p>
  *                      <p>
  *                      You should not add a terminating semicolon or \g
  *                      to the statement.
  *                      </p>
  *                      <p>
  *                      The markers are legal only in certain places in SQL statements.
  *                      For example, they are allowed in the VALUES() list of an INSERT statement
  *                      (to specify column values for a row), or in a comparison with a column in
  *                      a WHERE clause to specify a comparison value.
  *                      </p>
  *                      <p>
  *                      However, they are not allowed for identifiers (such as table or column names),
  *                      in the select list that names the columns to be returned by a SELECT statement),
  *                      or to specify both operands of a binary operator such as the =
  *                      equal sign. The latter restriction is necessary because it would be impossible
  *                      to determine the parameter type. In general, parameters are legal only in Data
  *                      Manipulation Language (DML) statements, and not in Data Definition Language
  *                      (DDL) statements.
  *                      </p>
  *
  * @return bool false on error
  * @since 5.0
  */
 public function prepare($query)
 {
     $this->_sql = $query;
     $this->_sql_with_bound_parameters = $query;
     if (!$this->_db->isReady()) {
         return false;
     }
     if (!$query || $query === '') {
         $this->_debug->displayError('Can\'t prepare an empty Query', false);
         return false;
     }
     $bool = parent::prepare($query);
     if ($bool === false) {
         $this->_debug->displayError('Can\'t prepare Query: ' . $query . ' | ' . $this->error, false);
     }
     return true;
 }
開發者ID:voku,項目名稱:simple-mysqli,代碼行數:53,代碼來源:Prepare.php


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