本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}