RE: forgetting to close db connection

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

 



Hi

If you have a large number of users updating the same database there are a
wide range of issues that come into play.

I am assuming you have a web interface, if not the following  does not
apply.

The web is stateless. By that I mean that there is no persistent connection
between your page and the server, unlike a desktop database like Access.

Your browser requests a page, your webserver generates the page, in
co-operation with php and MySql. The whole page is then returned and your
browser displays it. Although your php script may not  explicitly disconnect
from MySql, once the request has been fulfilled it will do it automatically.

This is a simplified overview, and there are tricks that allow slightly
different behaviour, but this is how it generally  works.

Unlike a desktop database, MySql does not lock the data while you update it,
so you need to manage the case where two users might edit the same data and
overwrite each others changes. Like web pages, MySql does its job in
transactions. You send the instruction to MySql, it completes the
transaction and then disconnects. So, from a data point of view, your user
requests a copy of the record, MySql sends the data, with no idea what your
user will do with it. When the editing is complete your user's browser sends
the edited data back, and php tells MySql to execute an update of some sort
using the data the browser sent back. MySql does not check to see if the
data has changed since you requested it in the first place.

There have been a few discussions about record locking over the last month
or so, which would be worth reading.

700 users constantly updating data is quite a lot. If you get to that stage
you may need a hosting solution to match, 20 users should not present any
problems for most web hosts.

Hope this gives a clearer picture.

Peter






















> -----Original Message-----
> From: Matthew Perry [mailto:matt@xxxxxxxxxxxxxxxxxxxxxx]
> Sent: 12 December 2004 15:23
> Cc: php-db@xxxxxxxxxxxxx
> Subject:  forgetting to close db connection
>
>
> On my forms I connect to my database each page that I need to update the
> data.
> I do not disconnect at the end of the page.
> Very soon I will have about 20-700 entering data simultaneously.  I
> might use this javascript code sent by Peter.  This will probably lead
> to a pretty huge overhead.
> Is not disconnecting on every page going to cause any problems?  Are
> there any other concerns I should consider?
>
> Matthew
>
>
> Peter Lovatt wrote:
>
> >You could use JavaScript
> >
> ><form action="somescript.php" name="dataform" id="dataform">
> ><textarea cols="30" rows="5" name="data_text"
> >onBlur="dataform.submit()"></textarea>
> ></form>
> >
> >
> >onblur executes when the user leaves the box, and will submit the form
> >
> >HTH
> >
> >Peter
> >
> >
> >
> >
> >>-----Original Message-----
> >>From: Matthew Perry [mailto:matt@xxxxxxxxxxxxxxxxxxxxxx]
> >>Sent: 12 December 2004 05:12
> >>To: php-db@xxxxxxxxxxxxx
> >>Subject:  save as you type
> >>
> >>
> >>Is there a way to make an input box save data into a database as users
> >>type?  My users keep forgetting to press my "apply changes" buttons.
> >>Matthew
> >>
> >>--
> >>PHP Database Mailing List (http://www.php.net/)
> >>To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >>
> >
> >
> >
> >
> >
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux