php-general Digest 31 May 2009 12:18:54 -0000 Issue 6151

Topics (messages 293396 through 293398):

Re: recipes anyone?
        293396 by: Clancy

Re: How To Limit FIle Uploader Against Hijackers?
        293397 by: Nitsan Bin-Nun

mysql_query takes long time...
        293398 by: דניאל דנון

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
On Sat, 30 May 2009 14:31:26 -0400, [email protected] (PJ) wrote:


>> So, if corn is bad, eating it will get rid of it faster right? :p

>No it will turn you into a corn cob! ;-)

Which is why Christopher Columbus found the Americas uninhabited! ;-)


--- End Message ---
--- Begin Message ---
That's what I thought, I just wanted to make sure I'm on the right path :)

Thank you


On 5/31/09, Michael A. Peters <[email protected]> wrote:
>
> Nitsan Bin-Nun wrote:
>
>> What do you mean by session variables?
>> I should register a new session and pass it along with the file to the PHP
>> wrapper?
>>
>
> Yes - in the page that links to your downloads you can do something like
>
> $_SESSION['download']=TRUE;
>
> then in the wrapper -
>
> if (isset($_SESSION['download'])) {
>   $allowed=$_SESSION['download']
>   } else {
>   $allowed=FALSE;
>   }
>
> the check the $allowed variable.
>
> Only way the file will be sent is if they have been to your site that
> creates a session for them and sets the $_SESSION['download'] variable to
> TRUE.
>
> You can check whatever you want from the session variables.
>
> For some of my files, I check the userid in the session variable and make
> sure the user is allowed to download it. If they aren't, they get a 401
> forbidden header and page.
>

--- End Message ---
--- Begin Message ---
I've a file of about 500,000 lines, each line contains a string in variety
of lengths, but no less then 3 characters and  usually no more then.... 120.
average of about 80, and maximum of about 250.

I made a PHP script to fetch the data (using fgets), process it and insert
it to a MySQL database.

The problem is inserting to MySQL takes about 0.02 seconds, which looks like
nothing - but when you have 500,000 lines to insert...
The while goes like that:

fgets from file
x1 = some function about the string
x2 = some other function about the string
x3 = the string
insert into table (field1, field2, field3) VALUES (x1, x2, x3)

(pseudo-code)

I was wondering, is there any faster way to perform it, assuming I have to
do it with PHP?
also, if it matters - the MySQL table got id in auto increment.


Yours, Daniel.

-- 
Use ROT26 for best security

--- End Message ---

Reply via email to