[PHP] Resource id #X

2005-08-18 Thread Chris Boget
I just want to make sure of my understanding on something.  I was pretty
sure I 
had this down but now I'm beginning to question myself and I'm hoping
someone
could confirm.

* User A accesses page X, which makes a connection to the database.
Echoing
out the result of the mssql_pconnect() function shows it's using
'Resource id #10'.
* User B accesses the same page, X, making another connection to the
database.
Echosing out the result of the pconnection function shows it's using
'Resource id
#10'
 
Now, even though they are showing the same resource id, it's not
actually the
same connection, correct?  Such that when page X begins a transaction
for
both User A and User B, when that page executes the query and either
commits
or rolls back the transaction, it won't be committing or rolling back
the transaction
for the wrong user, correct?  So something like this wouldn't happen
 
BEGIN TRAN (user a)
BEGIN TRAN (user b)
Query (user b)
Query (user a)
ROLLBACK (user b)
COMMIT (user a)
 
with User B rolling back User A's transaction and User A committing User
B's
transaction (or no transaction at all).
 
My understanding is that the above could never happen and although it
shows the 
same resource id for both users, it is, in fact, two connections.
However, some
things have been occuring over the last few days that has been shaking
my under-
standing and I just want to confirm the above and rule this out as a
possible cause
for the funkiness I've been seeing.
 
thnx,
Chris
 
 


Re: [PHP] Resource id #X

2005-08-18 Thread Richard Lynch
On Thu, August 18, 2005 1:00 am, Chris Boget wrote:
 * User A accesses page X, which makes a connection to the database.
 Echoing
 out the result of the mssql_pconnect() function shows it's using
 'Resource id #10'.
 * User B accesses the same page, X, making another connection to the
 database.
 Echosing out the result of the pconnection function shows it's using
 'Resource id
 #10'

 Now, even though they are showing the same resource id, it's not
 actually the
 same connection, correct?

Correct.

If you echo out EVERY connection/result/resource, you will see that
PHP pretty much just starts counting at 1 at the beginning of a script
and increments the resource counter on each resource.

Change the script to, say, connect to some other database at the top,
and everything will be off by 1 from the previous user.

 BEGIN TRAN (user a)
 BEGIN TRAN (user b)
 Query (user b)
 Query (user a)
 ROLLBACK (user b)
 COMMIT (user a)

 with User B rolling back User A's transaction and User A committing
 User
 B's
 transaction (or no transaction at all).

Hm.

Take out the _pconnect.

Or switch to MySQL or PostgreSQL maybe for a test, just to see if
their transactions exhibit the same behaviour.

SQL Server is the least-broken Microsoft product...

You could also try using the Sybase drivers to connect to MS SQL.

Last I heard, they were faster anyway.  Though it's been years since
anybody has had enough money to get me to use an MS product.

-- 
Like Music?
http://l-i-e.com/artists.htm

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