0

PDO は少しトリッキーに思えますが、私は大規模なデータベースを持っており、このエラーが発生しています。

Fatal error: Allowed memory size of 100663296 bytes exhausted (tried to allocate 256 bytes)

使用するときは、

fetchAll()

それを解決する最良の方法は何ですか?

4

1 に答える 1

3

You can temporarily allocate extra memory using:

ini_set('memory_limit', '750M');

The actual problem is PHP itself not PDO per-se... the PHP Array it's creating is too big... try above... obviously 750M is a lot but ya get the idea!

You will probably fine in php.ini memory_limit is 128M by default ... resulting in the error you're getting when the script execution over all exceeds this.

ALTERNATIVELY:

(as per my comments) - Only fetch what you can display for the user, i.e. implement some form of Paging.

A great combination is using jQuery Datatables and server-side pipeline of data. I.e. it will fetch from DB for each page as requested.

ALSO:

Make sure your schema has been properly designed and normalised and not just got 100's of columns!

于 2012-07-05T15:29:49.813 に答える