Re: mssql_* overhead
| From: | Sancar Saran | Date: | Thu, 11 Jan 2007 09:04:15 +0000 |
| Subject: | Re: mssql_* overhead | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-246890@lists.php.net to get a copy of this message | ||
On Wednesday 10 January 2007 17:47, Philip Thompson wrote:
> Hi.
>
> Does anyone know if the mssql_connect/_init/_bind/etc require a lot
> of overhead?
>
> I have a page that requires multiple function calls and each of those
> opens a new connection to the database, performs the necessary
> actions in stored procedure(s), and then closes the connection.
> However, I found this to be slower than I was wanting. So I thought,
> just create one connection and assign it to the SESSION (a global),
> and in each function that requires a connection, call that SESSION
> variable. At the end of the page, close the connection and nullify
> the variable.
>
> Does anyone see a problem with doing it this way? Security concerns?
> Anything?
>
> Thanks in advance,
> ~Philip
Using pconnect solves your problem (if I understood correctly (I had liddle
English knowladge). Putting data into $_SESSION may bit slower because every
time you nullf the variable and that means php have to serialize $_SESSION
and wrote into disk. (You may use SQL or Memcached base sessions)
just generate for example $_db variable and make it global, call every
function. if your regenerate your db connection data every time you init the
script, you don't need to store int $_SESSION.
$_SESSION gives you state, not security. Actually it stores data into disk (or
sql or memory (depends your config)) per connection state (PHPSESSID).
and if you bored declaring global $_db in ever function you may use
$GLOBALS['_db'] = $_db
then call in other functions
and if you want speed use Memcached. Using SQL for state like using Tractor
in F1 Race.
Regards
Sancar