Re: newbie questions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ravi wrote:

Guys, I am fairly new to PHP. Here are a few questions, if anybody can answer it will help me get started. Thanks

I am trying to build a website and I would like to do the following in my scripts

1. I want to return response to the browser and AFTERWARDS make a log entry in to a database. I need this so user can experience a fast response.
There is no "before and after". Everything you do happens during (part of) the response. But you can just output your data, whatever it may be, flush() it and then log it via the same script. Your user won't notice a thing (Hell, even without the flush your user won't notice it probably).

2. If the database update fails, I want to ignore it (since it is just log entry). Something like try-catch construct in Java. This is more important if item1 mentioned above is not possible. Essentially whether I make a database entry or not, I must return a valid response to user.
So ignore it :) If you don't check for errors, you won't see them... Makes debugging very annoying, but you won't see em nevertheless. If your output is not based on anything from your database-update, then there apparently is no need to worry about it.

3. Is there something like connection pool in php? Do usually people open/close database connection for every request (I doubt that, it sounds really slow).
There is something like that, the persistent connections (ie. via mysql_pconnect), but generally people DO open/close connections via the same script each and every time the script is executed (this might sound very slow, but it's actually not too bad). Using persistent connections is not always the best option (and usually doesn't even make much sense); there's a good bit of documentation about it in the php docs:
http://www.php.net/manual/en/features.persistent-connections.php

Some code samples or pointers to documentation for the above would also be very helpful.
code samples of what exactly ?

Thanks
Ravi

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux