本文整理汇总了PHP中mysqli_stmt_free_result函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_stmt_free_result函数的具体用法?PHP mysqli_stmt_free_result怎么用?PHP mysqli_stmt_free_result使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysqli_stmt_free_result函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: closeCursor
public function closeCursor()
{
if ($this->_result) {
$this->fetch_fields = array();
$this->fetch_out = null;
mysqli_stmt_free_result($this->_result);
}
}
示例2: mysqli_fetch_array_large
function mysqli_fetch_array_large($offset, $link, $package_size)
{
/* we are aiming for maximum compression to test MYSQLI_CLIENT_COMPRESS */
$random_char = str_repeat('a', 255);
$sql = "INSERT INTO test(label) VALUES ";
while (strlen($sql) < $package_size - 259) {
$sql .= sprintf("('%s'), ", $random_char);
}
$sql = substr($sql, 0, -2);
$len = strlen($sql);
assert($len < $package_size);
if (!@mysqli_query($link, $sql)) {
if (1153 == mysqli_errno($link) || 2006 == mysqli_errno($link) || stristr(mysqli_error($link), 'max_allowed_packet')) {
/*
myslqnd - [1153] Got a packet bigger than 'max_allowed_packet' bytes
libmysql -[2006] MySQL server has gone away
*/
return false;
}
printf("[%03d + 1] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link));
return false;
}
/* buffered result set - let's hope we do not run into PHP memory limit... */
if (!($res = mysqli_query($link, "SELECT id, label FROM test"))) {
printf("[%03d + 2] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link));
return false;
}
while ($row = mysqli_fetch_assoc($res)) {
if ($row['label'] != $random_char) {
printf("[%03d + 3] Wrong results - expecting '%s' got '%s', len = %d, [%d] %s\n", $offset, $random_char, $row['label'], $len, mysqli_errno($link), mysqli_error($link));
return false;
}
}
mysqli_free_result($res);
if (!($stmt = mysqli_prepare($link, "SELECT id, label FROM test"))) {
printf("[%03d + 4] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link));
return false;
}
/* unbuffered result set */
if (!mysqli_stmt_execute($stmt)) {
printf("[%03d + 5] len = %d, [%d] %s, [%d] %s\n", $offset, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), mysqli_errno($link), mysqli_error($link));
return false;
}
$id = $label = NULL;
if (!mysqli_stmt_bind_result($stmt, $id, $label)) {
printf("[%03d + 6] len = %d, [%d] %s, [%d] %s\n", $offset, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), mysqli_errno($link), mysqli_error($link));
return false;
}
while (mysqli_stmt_fetch($stmt)) {
if ($label != $random_char) {
printf("[%03d + 7] Wrong results - expecting '%s' got '%s', len = %d, [%d] %s\n", $offset, $random_char, $label, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
}
mysqli_stmt_free_result($stmt);
mysqli_stmt_close($stmt);
return true;
}
示例3: queueNotify
function queueNotify($type, $data)
{
$connection = mappedConnection('queue');
$sql = 'INSERT INTO queue (event) VALUES (?);';
$statement = mysqli_prepare($connection, $sql);
$value = serialize(['type' => $type, 'data' => $data]);
mysqli_stmt_bind_param($statement, 's', $value);
mysqli_stmt_execute($statement);
mysqli_stmt_free_result($statement);
}
示例4: insertLogingegevens
function insertLogingegevens($PersoonID, $Gebruikersnaam, $Wachtwoord)
{
$link = connect();
$stmt = mysqli_prepare($link, "INSERT INTO Logingegevens(PersoonID, Gebruikersnaam, Wachtwoord) VALUES(?, ?, ?);");
mysqli_stmt_bind_param($stmt, "iss", $PersoonID, $Gebruikersnaam, $Wachtwoord);
mysqli_stmt_execute($stmt);
mysqli_stmt_free_result($stmt);
mysqli_stmt_close($stmt);
mysqli_close($link);
}
示例5: test_format
function test_format($link, $format, $from, $order_by, $expected, $offset)
{
if (!($stmt = mysqli_stmt_init($link))) {
printf("[%03d] Cannot create PS, [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
return false;
}
if ($order_by) {
$sql = sprintf('SELECT %s AS _format FROM %s ORDER BY %s', $format, $from, $order_by);
} else {
$sql = sprintf('SELECT %s AS _format FROM %s', $format, $from);
}
if (!mysqli_stmt_prepare($stmt, $sql)) {
printf("[%03d] Cannot prepare PS, [%d] %s\n", $offset + 1, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
if (!mysqli_stmt_execute($stmt)) {
printf("[%03d] Cannot execute PS, [%d] %s\n", $offset + 2, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
if (!mysqli_stmt_store_result($stmt)) {
printf("[%03d] Cannot store result set, [%d] %s\n", $offset + 3, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
if (!is_array($expected)) {
$result = null;
if (!mysqli_stmt_bind_result($stmt, $result)) {
printf("[%03d] Cannot bind result, [%d] %s\n", $offset + 4, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
if (!mysqli_stmt_fetch($stmt)) {
printf("[%03d] Cannot fetch result,, [%d] %s\n", $offset + 5, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
if ($result !== $expected) {
printf("[%03d] Expecting %s/%s got %s/%s with %s - %s.\n", $offset + 6, gettype($expected), $expected, gettype($result), $result, $format, $sql);
}
} else {
$order_by_col = $result = null;
if (!mysqli_stmt_bind_result($stmt, $order_by_col, $result)) {
printf("[%03d] Cannot bind result, [%d] %s\n", $offset + 7, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
reset($expected);
while ((list($k, $v) = each($expected)) && mysqli_stmt_fetch($stmt)) {
if ($result !== $v) {
printf("[%03d] Row %d - expecting %s/%s got %s/%s [%s] with %s - %s.\n", $offset + 8, $k, gettype($v), $v, gettype($result), $result, $order_by_col, $format, $sql);
}
}
}
mysqli_stmt_free_result($stmt);
mysqli_stmt_close($stmt);
return true;
}
示例6: executeQuery
/**
* @param string $query
* @param string $types
* @param ...$params
*
* @return array|null
*/
function executeQuery($query, $types = null, ...$params)
{
if ($types !== null) {
$stmt = mysqli_prepare(getConnection(), $query);
if (!mysqli_stmt_bind_param($stmt, $types, ...$params)) {
die('Could not bind query params.');
}
if (!mysqli_stmt_execute($stmt)) {
die('Could not execute mysqli statement.');
}
$result = mysqli_stmt_get_result($stmt);
mysqli_stmt_free_result($stmt);
return resultQuery($result);
}
$result = mysqli_query(getConnection(), $query);
return resultQuery($result);
}
示例7: zerofill
function zerofill($offset, $link, $datatype, $insert = 1)
{
mysqli_query($link, 'ALTER TABLE test_mysqli_stmt_bind_result_zerofill_table_1 DROP zero');
$sql = sprintf('ALTER TABLE test_mysqli_stmt_bind_result_zerofill_table_1 ADD zero %s UNSIGNED ZEROFILL', $datatype);
if (!mysqli_query($link, $sql)) {
// no worries - server might not support it
return true;
}
if (!mysqli_query($link, sprintf('UPDATE test_mysqli_stmt_bind_result_zerofill_table_1 SET zero = %s', $insert))) {
printf("[%03d] UPDATE failed, [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
return false;
}
if (!($stmt = mysqli_prepare($link, 'SELECT zero FROM test_mysqli_stmt_bind_result_zerofill_table_1 LIMIT 1'))) {
printf("[%03d] SELECT failed, [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
return false;
}
$result = null;
if (!mysqli_stmt_bind_result($stmt, $result)) {
printf("[%03d] Bind failed, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) {
printf("[%03d] Execute or fetch failed, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
$res = mysqli_stmt_result_metadata($stmt);
$meta = mysqli_fetch_fields($res);
mysqli_stmt_free_result($stmt);
$meta = $meta[0];
$length = $meta->length;
if ($length > strlen($insert)) {
$expected = str_repeat('0', $length - strlen($insert));
$expected .= $insert;
if ($expected !== $result) {
printf("[%03d] Expecting '%s' got '%s'\n", $offset, $expected, $result);
return false;
}
} else {
if ($length <= 1) {
printf("[%03d] Length reported is too small to run test\n", $offset);
return false;
}
}
return true;
}
示例8: func_test_mysqli_stmt_num_rows
function func_test_mysqli_stmt_num_rows($stmt, $query, $expected, $offset)
{
if (!mysqli_stmt_prepare($stmt, $query)) {
printf("[%03d] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
if (!mysqli_stmt_execute($stmt)) {
printf("[%03d] [%d] %s\n", $offset + 1, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
if (!mysqli_stmt_store_result($stmt)) {
printf("[%03d] [%d] %s\n", $offset + 2, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
return false;
}
if ($expected !== ($tmp = mysqli_stmt_num_rows($stmt))) {
printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 3, gettype($expected), $expected, gettype($tmp), $tmp);
}
mysqli_stmt_free_result($stmt);
return true;
}
示例9: getReviews_paged
/**
* Returns $numItems rows starting from the $startIndex row from the
* table.
*
* Add authorization or any logical checks for secure access to your data
*
*
*
* @return array
*/
public function getReviews_paged($startIndex, $numItems)
{
//mysqli_query($this->connection, "set names utf8");
$stmt = mysqli_prepare($this->connection, "SELECT * FROM {$this->tablename} LIMIT ?, ?");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'ii', $startIndex, $numItems);
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
$rows = array();
mysqli_stmt_bind_result($stmt, $row->id, $row->restaurantName, $row->icon, $row->starRating, $row->starImageLoc, $row->reviewSubmitDate, $row->userName, $row->description);
while (mysqli_stmt_fetch($stmt)) {
$rows[] = $row;
$row = new stdClass();
mysqli_stmt_bind_result($stmt, $row->id, $row->restaurantName, $row->icon, $row->starRating, $row->starImageLoc, $row->reviewSubmitDate, $row->userName, $row->description);
}
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
return $rows;
}
示例10: close
public function close()
{
mysqli_stmt_free_result($this->res);
mysqli_stmt_close($this->res);
}
示例11: session_start
<?php
require_once 'connectdb.php';
session_start();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$username = trim($_POST["username"]);
$password = trim($_POST["password"]);
try {
$sql = "SELECT * FROM userprofile where userName='" . $username . "' and passw='" . $password . "'";
if ($result = mysqli_query($connection, $sql)) {
if ($row = mysqli_fetch_assoc($result)) {
$userfullname = $row['name'];
$userid = $row['userId'];
$_SESSION['fname'] = $userfullname;
$_SESSION['userid'] = $userid;
$_SESSION['login'] = 1;
header("location: ../home.php");
} else {
$message = "Invalid user!";
echo "<script type='text/javascript'>alert('{$message}');window.location.href = '../home.php?error';</script>";
}
mysqli_stmt_free_result($stmt);
mysqli_close($connection);
}
} catch (Exception $e) {
die(var_dump($e));
}
}
示例12: isWaiting
function isWaiting($conn, $UserId, $BlockId)
{
$stmt = mysqli_prepare($conn, "select * from WaitingList where WUserid = ? and Blockid = ?");
mysqli_stmt_bind_param($stmt, "ii", $UserId, $BlockId);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
$num = mysqli_stmt_num_rows($stmt);
mysqli_stmt_free_result($stmt);
mysqli_stmt_close($stmt);
if ($num > 0) {
return true;
}
return false;
}
示例13: doQuery
/**
* Perform a query
* @param string $queryText The prepared SQL statement that will be executed
* @param bool|string $typeDef (Optional) The types of values that will be passed through the prepared statement. One letter per parameter
* @param bool|array $params (Optional) The array of values that will be binded to the prepared statement
* @return mixed Returns an array of the values received from the query or returns false on empty
*/
private function doQuery($queryText, $typeDef = false, $params = false)
{
$multiQuery = true;
if ($stmt = $this->dbc->prepare($queryText)) {
if (count($params) == count($params, 1)) {
$params = array($params);
$multiQuery = false;
}
if ($typeDef) {
$bindParams = array();
$bindParamsReferences = array();
$bindParams = array_pad($bindParams, (count($params, 1) - count($params)) / count($params), "");
foreach ($bindParams as $key => $value) {
$bindParamsReferences[$key] =& $bindParams[$key];
}
array_unshift($bindParamsReferences, $typeDef);
$bindParamsMethod = new ReflectionMethod('mysqli_stmt', 'bind_param');
$bindParamsMethod->invokeArgs($stmt, $bindParamsReferences);
}
$result = array();
foreach ($params as $queryKey => $query) {
if ($typeDef) {
foreach ($bindParams as $paramKey => $value) {
$bindParams[$paramKey] = $query[$paramKey];
}
}
$queryResult = array();
if ($stmt->execute()) {
$resultMetaData = $stmt->result_metadata();
$this->last_id = $stmt->insert_id;
if ($resultMetaData) {
$stmtRow = array();
$rowReferences = array();
while ($field = $resultMetaData->fetch_field()) {
$rowReferences[] =& $stmtRow[$field->name];
}
mysqli_free_result($resultMetaData);
$bindResultMethod = new ReflectionMethod('mysqli_stmt', 'bind_result');
$bindResultMethod->invokeArgs($stmt, $rowReferences);
while (mysqli_stmt_fetch($stmt)) {
$row = array();
foreach ($stmtRow as $key => $value) {
$row[$key] = $value;
}
$queryResult[] = $row;
}
mysqli_stmt_free_result($stmt);
} else {
$queryResult[] = mysqli_stmt_affected_rows($stmt);
}
} else {
$this->error($this->dbc->error, $this->dbc->errno);
$queryResult[] = false;
}
$result[$queryKey] = $queryResult;
}
mysqli_stmt_close($stmt);
} else {
$result = false;
}
if ($this->dbc->error) {
$this->error($this->dbc->error, $this->dbc->errno);
}
if ($multiQuery) {
return $result;
} else {
return $result[0];
}
}
示例14: getTraceInTimeline_paged
/**
* Returns $numItems rows starting from the $startIndex row from the
* table.
*
* Add authorization or any logical checks for secure access to your data
*
*
*
* @return array
*/
public function getTraceInTimeline_paged($startIndex, $numItems) {
$stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename LIMIT ?, ?");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'ii', $startIndex, $numItems);
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
$rows = array();
mysqli_stmt_bind_result($stmt, $row->id, $row->idTimeline, $row->idTrace, $row->idSelector, $row->position, $row->delay, $row->visible);
while (mysqli_stmt_fetch($stmt)) {
$rows[] = $row;
$row = new stdClass();
mysqli_stmt_bind_result($stmt, $row->id, $row->idTimeline, $row->idTrace, $row->idSelector, $row->position, $row->delay, $row->visible);
}
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
return $rows;
}
示例15: printf
}
if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) {
printf("[008] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
}
if (false !== ($tmp = mysqli_stmt_store_result($stmt))) {
printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
}
mysqli_stmt_close($stmt);
if (!($stmt = mysqli_stmt_init($link))) {
printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test_mysqli_stmt_free_result_table_1 ORDER BY id")) {
printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
}
if (!mysqli_stmt_execute($stmt)) {
printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
}
if (true !== ($tmp = mysqli_stmt_store_result($stmt))) {
printf("[013] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
}
if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) {
printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
}
mysqli_stmt_close($stmt);
if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) {
printf("[015] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
}
mysqli_close($link);
print "done!";
$test_table_name = 'test_mysqli_stmt_free_result_table_1';
require_once "clean_table.inc";