本文整理汇总了PHP中mysqli_stmt::bind_result方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_stmt::bind_result方法的具体用法?PHP mysqli_stmt::bind_result怎么用?PHP mysqli_stmt::bind_result使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysqli_stmt
的用法示例。
在下文中一共展示了mysqli_stmt::bind_result方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchResource
/**
* @param \mysqli_stmt $resource
* @param string $column
*
* @return mixed[]
*/
protected function fetchResource($resource, $column)
{
$result = [];
$metadata = $resource->result_metadata();
$fields = $metadata->fetch_fields();
if (count($fields) == 0) {
return [];
}
$variables = [];
$data = [];
foreach ($fields as $field) {
$variables[] =& $data[$field->name];
}
$resource->bind_result(...$variables);
while ($resource->fetch()) {
$clone = [];
foreach ($data as $key => $value) {
$clone[$key] = $value;
}
$result[] = $clone;
}
$resource->free_result();
$this->fixTypes($result, $fields, $column);
return $result;
}
示例2: caricaIndirizzoDaStmt
/**
* Carica un indirizzo eseguendo un prepared statement
* @param mysqli_stmt $stmt
* @return null
*/
public function caricaIndirizzoDaStmt(mysqli_stmt $stmt)
{
if (!$stmt->execute()) {
error_log("[caricaIndirizzoDaStmt] impossibile" . " eseguire lo statement");
return null;
}
$row = array();
$bind = $stmt->bind_result($row['id'], $row['destinatario'], $row['via_num'], $row['citta'], $row['provincia'], $row['cap'], $row['telefono']);
if (!$bind) {
error_log("[caricaIndirizzoDaStmt] impossibile" . " effettuare il binding in output");
return null;
}
if (!$stmt->fetch()) {
return null;
}
$stmt->close();
return self::creaIndirizzoDaArray($row);
}
示例3: array
/**
* Carica una lista di articoli eseguendo un prepared statement
* @param mysqli_stmt $stmt
* @return null
*/
public function &caricaArticoliDaStmt(mysqli_stmt $stmt)
{
$articoli = array();
if (!$stmt->execute()) {
error_log("[caricaArticoliDaStmt] impossibile" . " eseguire lo statement");
return null;
}
$row = array();
$bind = $stmt->bind_result($row['id'], $row['size'], $row['qty'], $row['prezzo'], $row['pizza_id']);
if (!$bind) {
error_log("[caricaArticoliDaStmt] impossibile" . " effettuare il binding in output");
return null;
}
while ($stmt->fetch()) {
$articoli[] = self::creaArticoloDaArray($row);
}
$stmt->close();
return $articoli;
}
示例4: array
public function &creaAlbumDaStmt(mysqli_stmt $stmt)
{
$album = array();
if (!$stmt->execute()) {
error_log("[creaAlbumDaStmt] impossibile" . " eseguire lo statement");
return null;
}
$row = array();
$bind = $stmt->bind_result($row['id'], $row['nome'], $row['autore'], $row['prezzo']);
if (!$bind) {
error_log("[creaAlbumDaStmt] impossibile" . " effettuare il binding in output");
return null;
}
while ($stmt->fetch()) {
$album = self::creaAlbumDaArray($row);
}
$stmt->close();
return $album;
}
示例5: caricaStudenteDaStmt
/**
* Carica uno studente eseguendo un prepared statement
* @param mysqli_stmt $stmt
* @return null
*/
private function caricaStudenteDaStmt(mysqli_stmt $stmt)
{
if (!$stmt->execute()) {
error_log("[caricaStudenteDaStmt] impossibile" . " eseguire lo statement");
return null;
}
$row = array();
$bind = $stmt->bind_result($row['studenti_id'], $row['studenti_nome'], $row['studenti_cognome'], $row['studenti_matricola'], $row['studenti_email'], $row['studenti_citta'], $row['studenti_via'], $row['studenti_cap'], $row['studenti_provincia'], $row['studenti_numero_civico'], $row['studenti_username'], $row['studenti_password'], $row['CdL_id'], $row['CdL_nome'], $row['CdL_codice'], $row['dipartimenti_id'], $row['dipartimenti_nome']);
if (!$bind) {
error_log("[caricaStudenteDaStmt] impossibile" . " effettuare il binding in output");
return null;
}
if (!$stmt->fetch()) {
return null;
}
$stmt->close();
return self::creaStudenteDaArray($row);
}
示例6: array
/**
* Popola una lista di corsi di laurea con una query variabile
* Attenzione: non popola il collegamento ai Dipartimenti
* @param mysqli_stmt $stmt
* @return array|\CorsoDiLaurea
*/
private function &inizializzaListaCorsi(mysqli_stmt $stmt)
{
$corsi = array();
if (!$stmt->execute()) {
error_log("[inizializzaListaCorsi] impossibile" . " eseguire lo statement");
return $corsi;
}
$id = 0;
$nome = "";
$codice = "";
if (!$stmt->bind_result($id, $codice, $nome)) {
error_log("[inizializzaListaCorsi] impossibile" . " effettuare il binding in output");
return array();
}
while ($stmt->fetch()) {
$corso = new CorsoDiLaurea();
$corso->setCodice($codice);
$corso->setNome($nome);
$corso->setId($id);
$corsi[] = $corso;
}
return $corsi;
}
示例7: array
public function &caricaPODaStmt(mysqli_stmt $stmt)
{
$po = array();
if (!$stmt->execute()) {
error_log("[caricaPODaStmt] impossibile" . " eseguire lo statement");
return null;
}
$row = array();
$bind = $stmt->bind_result($row['albumId'], $row['ordineId'], $row['id'], $row['quantita']);
if (!$bind) {
error_log("[caricaPODaStmt] impossibile" . " effettuare il binding in output");
return null;
}
while ($stmt->fetch()) {
$po[] = self::creaPODaArray($row);
}
$stmt->close();
return $po;
}
示例8: checkBindResult
/**
* Prepare a statement, but in a way that checks the result, and errors out when it fails.
* @param mysqli $db
* @param mysqli_stmt $stmt
* @param mixed $var1
* @param mixed $var2
* @param mixed $var3
* @param mixed $var4
*/
function checkBindResult($db, $stmt, &$var1, &$var2 = NULL, &$var3 = NULL, &$var4 = NULL)
{
$num = func_num_args();
if ($num == 3) {
$result = $stmt->bind_result($var1);
} else {
if ($num == 4) {
$result = $stmt->bind_result($var1, $var2);
} else {
if ($num == 5) {
$result = $stmt->bind_result($var1, $var2, $var3);
} else {
if ($num == 6) {
$result = $stmt->bind_result($var1, $var2, $var3, $var4);
}
}
}
}
if ($result === FALSE) {
stmtError($db, $stmt);
}
}
示例9:
<?php
require_once "connect.inc";
$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$stmt = new mysqli_stmt($mysql, "SELECT 'foo' FROM DUAL");
$stmt->execute();
$stmt->bind_result($foo);
$stmt->fetch();
$stmt->close();
$mysql->close();
var_dump($foo);
示例10: array
if (mysqli_stmt_num_rows($stmtUser) == 1) {
mysqli_stmt_fetch($stmtUser);
$author['first_name'] = $fisrt_name;
$author['last_name'] = $last_name;
}
}
}
// preapre adventure data
$adventure = array();
$total_progress = 0;
// adventure
$stmtAdventure = new mysqli_stmt($mysqli, "SELECT a.id, a.name, a.description, rate.total_rate, p.id, p.file_ext\nFROM adventures a, photos p, users u, (\n\tSELECT a.id, (IFNULL(v.rate,0)+a.admin_vote) as total_rate\n\tFROM adventures a\n\tLEFT JOIN (\n\t\tSELECT id, COUNT(*) as rate, v.date\n\t\tFROM adventures a, votes v\n\t\tWHERE a.id = v.adv_id\n\t\tGROUP BY id\n\t) v\n\tON a.id = v.id\n) rate\nWHERE a.user_id = u.id\nAND u.id = ?\nAND a.id = rate.id\nAND (p.adv_id = a.id\nAND p.is_cover = 1)\nORDER BY rate.total_rate");
if ($stmtAdventure) {
$stmtAdventure->bind_param("i", $author['id']);
if ($stmtAdventure->execute()) {
$stmtAdventure->bind_result($ad_id, $name, $ad_description, $rate, $photoid, $photoext);
while ($stmtAdventure->fetch()) {
$adventure[] = array('id' => $ad_id, 'description' => $ad_description, 'name' => $name, 'pid' => $photoid, 'rate' => $rate, 'pext' => $photoext);
}
}
}
//$ad_total = $total_progress;
foreach ($adventure as $stone) {
?>
<div id="top1" class="container">
<div class="row">
<div class="col-md-3">
<img
src="./img/contents/<?php
echo $stone['pid'] . "." . $stone['pext'];
示例11: array
}
}
}
}
}
?>
<?php
$commentArray[] = array();
$sql = "SELECT * FROM comments WHERE adv_id = {$adv_id}";
$res = $mysqli->query($sql) or trigger_error($mysqli->error . "[{$sql}]");
while ($row = $res->fetch_assoc()) {
$stmt3 = new mysqli_stmt($mysqli, "SELECT first_name, last_name FROM users WHERE id = ?");
$stmt3->bind_param("i", $row['user_id']);
$stmt3->execute();
$stmt3->bind_result($commentFirstName, $commentLastName);
$stmt3->store_result();
if ($stmt3->num_rows() == 1) {
while ($stmt3->fetch()) {
?>
<div class="row">
<div
class="col-md-6 col-md-offset-1 comments-section">
<section>
<div class="">
<label
class=""><?php
示例12: array
private function &caricaAppelliDaStmt(mysqli_stmt $stmt)
{
$appelli = array();
if (!$stmt->execute()) {
error_log("[caricaInsegnamentoDaStmt] impossibile" . " eseguire lo statement");
return null;
}
$row = array();
$bind = $stmt->bind_result($row['appello_id'], $row['appello_data'], $row['appello_capienza'], $row['insegnamenti_id'], $row['insegnamenti_titolo'], $row['insegnamenti_cfu'], $row['insegnamenti_codice'], $row['docenti_id'], $row['docenti_nome'], $row['docenti_cognome'], $row['docenti_email'], $row['docenti_citta'], $row['docenti_cap'], $row['docenti_via'], $row['docenti_provincia'], $row['docenti_numero_civico'], $row['docenti_ricevimento'], $row['docenti_username'], $row['docenti_password'], $row['dipartimenti_id'], $row['dipartimenti_nome'], $row['CdL_id'], $row['CdL_nome'], $row['CdL_codice']);
if (!$bind) {
error_log("[caricaInsegnamentoDaStmt] impossibile" . " effettuare il binding in output");
return null;
}
while ($stmt->fetch()) {
$appelli[] = self::creaDaArray($row);
}
$stmt->close();
return $appelli;
}
示例13: caricaOrdiniDaStmt
/**
* Carica una lista di ordini eseguendo un prepared statement
* @param mysqli_stmt $stmt
* @return null
*/
public function caricaOrdiniDaStmt(mysqli_stmt $stmt)
{
$ordini = array();
if (!$stmt->execute()) {
error_log("[caricaOrdiniDaStmt] impossibile" . " eseguire lo statement");
return null;
}
$row = array();
$bind = $stmt->bind_result($row['id'], $row['data_conclusione'], $row['data_creazione'], $row['subtotale']);
if (!$bind) {
error_log("[caricaOrdiniDaStmt] impossibile" . " effettuare il binding in output");
return null;
}
while ($stmt->fetch()) {
$ordini[] = self::creaOrdineDaArray($row);
}
$stmt->close();
return $ordini;
}
示例14: caricaPagamentiDaStmt
/**
* Carica una lista di pagamenti eseguendo un prepared statement
* @param mysqli_stmt $stmt
* @param $flag : 1 -> un metodo | 2 -> piu' di uno
* @return null
*/
public function caricaPagamentiDaStmt(mysqli_stmt $stmt, $flag = 1)
{
if (!$stmt->execute()) {
error_log("[caricaPagamentiDaStmt] impossibile" . " eseguire lo statement");
return null;
}
$row = array();
$bind = $stmt->bind_result($row['id'], $row['saldo'], $row['num_carta'], $row['cod_carta'], $row['scadenza_carta'], $row['titolare_carta'], $row['tipo_carta']);
if (!$bind) {
error_log("[caricaPagamentiDaStmt] impossibile" . " effettuare il binding in output");
return null;
}
if ($flag == 1) {
if (!$stmt->fetch()) {
return null;
}
$stmt->close();
return self::creaPagamentoDaArray($row);
} else {
$pagamenti = array();
while ($stmt->fetch()) {
$pagamenti[] = self::creaPagamentoDaArray($row);
}
$stmt->close();
return $pagamenti;
}
}
示例15: AND
break;
case "author":
$query = "SELECT A.id, A.name FROM adventures A, users U WHERE A.user_id = U.id AND (CONCAT(first_name, ' ', last_name) LIKE ?)";
$bindType = 's';
$search = "%" . $search . "%";
break;
case "votes":
$query = "SELECT a.id, a.name\n FROM adventures a\n LEFT JOIN (\n SELECT id, COUNT(*) as rate, v.date\n FROM adventures a, votes v\n WHERE a.id = v.adv_id GROUP BY id\n ) v\n ON a.id = v.id\n WHERE (IFNULL(v.rate,0)+a.admin_vote) >= ?";
$bindType = 'i';
$search = (int) $search;
break;
}
$stmt = new mysqli_stmt($mysqli, $query);
if ($stmt->bind_param($bindType, $search)) {
$stmt->execute();
$stmt->bind_result($id, $name);
while ($stmt->fetch()) {
$search_results["data"][] = array("id" => $id, "name" => $name);
}
}
}
}
}
// PRINT SEARCH RESULTS
echo "<ul class='list-group'>";
foreach ($search_results["data"] as $key => $val) {
?>
<li>
<a href="./<?php
echo $search_type . ".php?id=" . $val['id'];
?>