|
Posted by J.O. Aho on 02/05/07 11:03
Erwin Moller wrote:
>> 1. Are there better ways to manage connections and easier data retrieval
>> to ensure performance of the site under heavy load?
>
> PHP recycles its connection behind your back.
> If scriptA.php connects to a database, a connection is build based on the
> login-credentials (host, database, username, password, etc).
>
> If scriptB.php, scriptC.php, etc, use the same logincredentials, which is
> almost always the case in webdriven databases, you'll find that they do NOT
> need the connection/authentication overhead that scriptA.pp needed.
That depends on which connect function you use, *_connect or *_pconnect.
> PHP remembers the logincredentials, DOESN'T CLOSE ITS CONNECTION, and
> recycles the connection when ANY script uses the same logincredentials.
If you use *_connect, the connection is closed when the script has been
executed, even if you don't use *_close, while *_pconnect leaves the
connection alive.
>> 2. Are there any potential pitfalls regarding my 2nd method of data
>> retrieval?
>
> Just be aware how your elements in your array represent 'strange values'
> coming from the database, like NULL. Are they stored as empty string? Or
> are they really (PHP)NULL? Make sure you check and know.
And don't get too much data, it's easier this way to hit the PHP max RAM size,
specially if you throw the data into functions in bad ways and you may have 2+
copies of the original array.
--
//Aho
[Back to original message]
|