Method 1: get_result()
:
*Note: This method only works with PHP >= 5.3, having the mysqlnd native driver.
Assuming this was done with MySQLi and you have bound these variables as result vars via bind_result()
, I would instead use get_result()
to transfer it into a MySQLi result resource, and fetch the rows as arrays onto an array containing all rows. Then use any pagination method or plugin you would normally use on array data:
// Don't use bind_result()...
// execute your statement
$stmt->execute();
// Get result set into a MySQLi result resource
$result = $stmt->get_result();
// array to hold all results
$rowset = array();
// And fetch with a while loop
while ($row = $result->fetch_assoc()) {
$rowset[] = $row;
}
? ? var_dump($rowset);
Now use $rowset
as a 2D array, with which you can use any pagination method that operates on regular arrays.
Method 2: build an array with bound output vars
If you don't have the mysqlnd native driver (and hence cannot use get_result()
, continue using bind_result()
but append all of those onto an array:
// array to hold all rows
$rowset = array();
// All results bound to output vars
while ($stmt->fetch()) {
// Append an array containing your result vars onto the rowset array
$rowset[] = array(
'email' => $Email,
'webpage' => $Webpage,
'telephone' => $Telephone,
'moblile' => $Mobile
);
}
var_dump($rowset);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…