PHP MySQL inserting data to multiple tables -


I'm trying to create a experimental web application that reduces redundant data. I have three set of example tables Is:

  table id | Created (Unix timestamp). Updated_at (Unix timestamp) table two ID. Foreign key on a table. Title Table Three (Page) ID Foreign key content for both one table and two. Metadata  

It is being thought that all the things created in the app will be a generation / editing time.

Many (but not all) things will be titled (for example, a page or a section for a page).

Finally, some things will have specific characteristics themselves, for example content and metadata for one page.

I am trying to prepare the best way to enter data in multiple tables. I know that I can do multiple insert queries from PHP, keep track of the rows created in the current transaction, and after removing those lines, the transaction should be part of after the failure, however, if the PHP script completely dies , Then it can be closed before all extinctions are completed.

Is there an inbuilt logic in MySQL that will allow to insert the inserted query? Will a trigger be able to handle this type of transaction or is it more than its capabilities?

Any advice, ideas or ideas will be highly appreciated.

Thank you!

A solution must be used, which allows access to "not all or nothing" behavior is.

The idea is as follows:

  • You start a transaction
  • You insert / update your
  • If everything is fine, then you do the transaction; Which will save everything you have done during this transaction
  • If not, you should withdraw the transaction;
  • If you do not comment and do not disconnect (for example, if your PHP script dies) , nothing will be done, and what will happen if you do not have any recommended lanes - done during the day, will roll-back automatically.

For more information, you can take a look at MySQL.


Note that transactions are only available for some DB engines:

  • does not support transactions
  • (It also supports the foreign key, for example - it is far more advanced that MyISAM) .

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -