我正在构建一个需要执行此SQL语句的块:
$sql = 'SELECT c.fullname AS CourseName, from_unixtime(l.time) AS DateandTime, u.username AS Username,
l.ip AS IPAddress, u.firstname AS FirstName, u.lastname AS LastName, u.email AS Email, l.module As Activity,
l.action As Action, l.url As URL, l.info AS Information, r.roleid AS RoleID, l.userid AS UserID, c.id as CourseID
FROM {log} l, {user} u, {role_assignments} r, {course} c
WHERE r.userid = l.userid AND c.id = ' . $courseid;
if($Flag == 0)
{
$sql = $sql . " ORDER BY DateandTime Desc";
}
elseif($Flag == 1)
{
$sql = $sql . " ORDER BY Username Asc";
}
其中“$ courseid”是选定的课程ID。执行时,Moodle返回此ERROR消息:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 2048 bytes) in D:\Moodle\lib\weblib.php on line 1277
我确实使用了这个php命令:
ini_set('memory_limit', '-1');
现在修改SQL语句后,我收到了这个错误:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 925 bytes) in D:\Moodle\lib\dml\moodle_database.php on line 842
刷新页面时,我会收到此错误:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 528 bytes) in D:\Moodle\lib\dml\mysqli_native_moodle_database.php on line 1022
但我知道这不是一个解决方案。
有人可以帮助我,我将不胜感激吗?
提前致谢。
致以最诚挚的问候,
艾哈迈德
答案 0 :(得分:2)
Moodle提供了一种方法raise_memory_limit($newlimit);
该函数在setuplib.php中声明,只要包含config.php就可用。
使用此方法是提高Moodle内存限制的首选方法。
按如下方式使用:
raise_memory_limit([MEMORY_STANDARD|MEMORY_EXTRA|MEMORY_HUGE|MEMORY_UNLIMITED|'128M'|...]);