Zoidberg
Zoidberg

Reputation: 11

Accessing MySQL from PHP and another process at the same time

I'm writing a program that runs (24/7) on a Linux server and adds entries to a MySQL database. The contents of the database are presented on a web interface with PHP and the user should be able to delete entries using the web interface. Is it possible to access the database from multiple processes at the same time?

Upvotes: 1

Views: 739

Answers (4)

Sandeepan Nath
Sandeepan Nath

Reputation: 10284

Yes and there will not be any problems while trying to delete records in the presence of that automated program which runs 24/7 if you are using the InnoDb engine. This is because transactions happen one at a time, one starts after another has finished and the database is consistent everytime.

This answer How to implement the ACID model for a database has many relevant points.

Read about the ACID Properties of a database. A Mysql database with InnoDb engine will take care of all these things for you and you need not worry about that.

Upvotes: 0

Oliver A.
Oliver A.

Reputation: 2900

Yes multiple users can access the database at the same time. You should however take care that the data is consistent. If you create/edit entry with many small sql statements and in the meantime someone useses the web interface this may lead to some errors. If you have a simple db this should not be a problem, else you should consider using transactions.

http://dev.mysql.com/doc/refman/5.0/en/ansi-diff-transactions.html

Upvotes: 0

David
David

Reputation: 218827

Yes, databases are designed for this purpose quite well. You'll want to keep a few things in mind in your designs:

  1. Concurrency and race conditions on database writes.
  2. Performance.
  3. Separate database permissions for separate applications.

Upvotes: 1

Parris Varney
Parris Varney

Reputation: 11478

Unless you're doing something like accessing the DB using a singleton, the max number of simultaneous mysql connections php will use is limited in your php.ini. I believe it defaults to 100.

Upvotes: 0

Related Questions