NYCPHP Meetup

NYPHP.org

[nycphp-talk] using PHP to import large-ish SQL into mysql

Marc Antony Vose suzerain at suzerain.com
Wed Oct 21 05:02:01 EDT 2009


Le Oct 21, 2009 à 8:11 AM, Daniel Convissor a écrit :

>> Problem is, the PHP script is terminating with a PHP error; server's
>> support thinks it's out of memory.
>
> Why should anyone be guessing what the issue is?  PHP's error messages
> explain exactly what the problem is in plain English.  Please post the
> actual error message.
>

Sorry...I made a typo there.  I  meant that the script is terminating  
with a 500 Error (NOT a PHP error)...which means there is no log or  
useful error trail.  All I see in the error_log is the dreaded  
"Premature end of script headers" error.

It usually points to out of memory or some other config error (like a  
bunk shebang line in a CGI).

In this case, the script works when I import the smaller tables, and  
gives the 500 Error when I try the larger tables, so I think out of  
memory is a pretty reasonable hypothesis.

As I said, PHP's memory_limit is set to 90M by default (according to  
phpinfo()) and I tried upping it to 128M, and phpinfo() says it's set  
to that, also, so I'm a bit confused as to why one 16 MB file would  
exceed 90M on import, but hey, who knows.


> Another thought, if this is (nearly) all you're doing, why involvine  
> PHP
> at all?  Do it directly in a shell script.
>

I was using PHP partly because it's the language I'm most familiar  
with, but more importantly because I don't want to automatically  
import certain files; the decision to import is based on logic in the  
script, and some of that logic comes from information in the bigger  
web application it's a part of.

I already rewrote the script in Perl, but still had issues with  
importing the larger tables there, too.

I'm not really much of a shell scripter; perhaps I should see if I can  
do it that way.

If anyone has any other strategy that can work in PHP, let me know.

Cheers,
Marc





More information about the talk mailing list