Reputation: 7740
This is the error I'm getting:
Allowed memory size of 1258291200 bytes exhausted (tried to allocate 4294967296 bytes)
on this line: call_user_func_array(array($query, 'bind_result'), $params);
Funnily enough, I've used this exact script dozens of time without issue. So I think it might be something in my server/db set up but can't think of anything.
Here's the full function:
public function q($query) {
if ($query = $this->_mysqli->prepare($query)) {
if (func_num_args() > 1) {
$x = func_get_args();
$args = array_merge(array(func_get_arg(1)),
array_slice($x, 2));
$args_ref = array();
foreach($args as $k => &$arg) {
$args_ref[$k] = &$arg;
}
call_user_func_array(array($query, 'bind_param'), $args_ref);
}
$query->execute();
if ($query->errno) {
if ($this->_debug) {
echo mysqli_error($this->_mysqli);
debug_print_backtrace();
}
return false;
}
if ($query->affected_rows > -1) {
return $query->affected_rows;
}
$params = array();
$meta = $query->result_metadata();
while ($field = $meta->fetch_field()) {
$params[] = &$row[$field->name];
}
call_user_func_array(array($query, 'bind_result'), $params);
$result = array();
while ($query->fetch()) {
$r = array();
foreach ($row as $key => $val) {
$r[$key] = $val;
}
$result[] = $r;
}
$query->close();
foreach($result as $key=>$resultField){
$result[$key] = (object) $resultField;
}
return $result;
} else {
if ($this->_debug) {
echo $this->_mysqli->error;
debug_print_backtrace();
}
return false;
}
}
Please do not tell me to increase the memory limit. I'm looking for a fix to the problem, not the symptom.
Upvotes: 0
Views: 49
Reputation: 7740
Turns out I was using longtext
unnecessarily and using up all my memory. Switching to mediumtext
solved the issue.
Upvotes: 1