Page 2 of 2
Re: Better way to implode a query string?
Posted: Fri Feb 12, 2010 3:48 pm
by incubi
With your example If/when I put $allrows[] inside the while loop I get a serious buffer issues that ends in crashing my browser so I can't give the resulting error messages.
Isn't there a way to append a string to the last element in and array? Not appending a new element to the array but modifying the last element within the array? That would allow me to place the ending bracket and problem solved.
Re: Better way to implode a query string?
Posted: Fri Feb 12, 2010 3:55 pm
by Eran
There might be too many rows that you are running out of memory on the server (that shouldn't crash your browser though). You could stop every several iterations (say 10 or 20) insert the rows and reset the $allrows variable. Aside from that, I've given you a working solution - if you make the effort to understand what's going in there I'm sure you'll be able to complete your requirements
Re: Better way to implode a query string?
Posted: Fri Feb 12, 2010 4:05 pm
by incubi
Its only 400 rows of data in a csv file with 23 columns and the server is the company dual xeon 8G ram server so I'm betting it not that. I don't use IE so that's out

I'll keep trying and see if I missed anything.
Thanks for the help.
incubi
Re: Better way to implode a query string? [SOLVED]
Posted: Fri Feb 12, 2010 4:31 pm
by incubi
pytrin
I found it, been a long day! I didn't put both the $row = array(); and the $allrows[] = "(" .implode(',',$row). ")"; in the loop. I called out the array $row before the loop and then when I moved it I had already moved the $allrows[] out of the loop.

I have a (Column count doesn't match value count at row 1) error but that's easy.
Thanks again for the help! Would you happen to have a working jetpack I can have too?
incubi
Re: Better way to implode a query string? [SOLVED]
Posted: Fri Feb 12, 2010 5:05 pm
by Eran
cheers, glad it worked out. regarding the memory issue I mentioned - PHP has a memory allocation in its configuration file, and its much lower than the entire server memory (imagine each php process taking up all the memory available to the server). Sometimes it's atrociously low (~ few megabytes) which could easily run out of memory for large arrays.