I have a table that has 2.3 MB of data (40,000 rows) that I tried to process using MySQLi/PHP. (I calculated the byte size of the table in the linked question)
error_reporting(E_ALL);
$q = "SELECT * FROM mytable";
if (!$result = $mysqli->query($q)) {
echo "Error: Our query failed to execute and here is why: \n";
echo "Query: " . $query . "\n";
echo "Errno: " . $mysqli->errno . "\n";
echo "Error: " . $mysqli->error . "\n";
return $ret;
}
if ($result->num_rows === 0) {
$ret = 0;
return $ret;
}
$ret = array();
while($row = $result->fetch_array()){
array_push($ret, $row);
}
echo mb_strlen(serialize((array)$ret), '8bit');
The following code gives:
On the following line:
while($row = $result->fetch_array()){
Am I doing a wrong approach at this or am taking too many rows? Or is this an issue with PHP?