运行 php 上的 mysqli 内存不足(256kB???)

Running out of memory with mysqli on php (256kB???)

我正在尝试通过 PHP 在 MySQL 数据库上执行 SELECT 语句。当我执行脚本时,出现致命错误:

Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 94020 bytes)

嗯,256kB 对每个人来说都不够,是吗?我该如何调整这个限制?

此致

克里斯

我的代码是:

ini_set('memory_limit', '1024MB');
  ...  
  // Create connection
  $mySQLConn = new mysqli($servername, $username, $password, $database);

  if ($mySQLConn->connect_error) {
    throw new Exception('Kann nicht auf DB verbinden: ' . $mySQLConn->connect_error);
  }
 
  
  $result = $mySQLConn->real_query("SELECT * FROM artikel;");
  $result = $mySQLConn->store_result(); // <- here I get this fatal error

https://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes 说:

What are all the available shorthand byte options?

The available options are K (for Kilobytes), M (for Megabytes) and G (for Gigabytes; available since PHP 5.1.0), and are all case-insensitive. Anything else assumes bytes. 1M equals one Megabyte or 1048576 bytes.

不要使用 1024MB。使用 1024M.