MySQL Forums
Forum List  »  PHP

Double Insert
Posted by: James Wilson
Date: October 14, 2019 12:16AM

My website consists of a backend Admin area where volunteer users add/edit records into various mySQL tables. Certain records added to a critical table are written to a self written transaction_log table. Along with certain specific elements of the record the query string used to Add/Edt/Del the record is also written to the log.

Some of the volunteer users live in an area where their internet connect is not the best. On occasion there will be a record that will turn up where all of the fields are null. In looking at the transaction log there will be two entries for the update with the first containing good information but at the same time a second record with all null parameters. Two issues...

1. The best solution would be to add something to the system would prevent the null record from being written. I am a newbie but have enough programming experience that I can make something work given an example.

2. As a 'solution' I have written a script that will take a good query string from the transaction log and simply use it as the input to an execute as follows...

$query_STR = urldecode($Query);
$query_PDO = $db->prepare($query_STR);
$query_PDO->execute();

But this throws an error. Any clues? Here is a sample Query string...

UPDATE interments_data SET per_cemid = 123, per_surname = 'Lomax', per_givenname = 'Tillman', per_middlename = 'George', per_maidenname = NULL, per_surname_prior = NULL, per_prefix = 'Capt', per_suffix = NULL, per_nickname = NULL, per_birthdate = '22 Oct 1823', per_deathdate = '18 Jan 1876', per_marriagedate = '1844', per_burialdate = NULL, per_birthplace = 'Abbeville, Abbeville Co., SC', per_deathplace = 'Holmes Co., MS', per_marriageplace = NULL, per_burialplot = NULL, per_plot_lat = NULL, per_plot_lon = NULL, per_tmbstn_img = NULL, per_tmbdtl_img = NULL, per_ftstn_img = NULL, per_plot_img = NULL, per_person_img = NULL, per_mil_img = NULL, per_mil_inscription = NULL, per_mil_notes = NULL, per_inscription = NULL, per_rech_notes = NULL, per_img_credits = NULL, per_deathcert = NULL, per_obit = NULL, per_obit_img = NULL, per_bio = NULL, per_bio_img = NULL, per_funcd_img = NULL, per_bio_page = NULL, per_family_page = NULL, per_parents = '<fg "m=178116454">Terrence Lomax - </fg>|10506', per_siblings = '<fg "m=25199009">James Avery Lomax</fg>|<fg "m=178454070">Dorothy <i>Lomax</i> Kelley</fg>|12345|12344|<hs></hs>|<fg "m=85048354">Aaron Lomax</fg>|<fg "m=178123226">Seaborn Lomax</fg>', per_spouse = 'Sarah Jane <i>Brownlee</i> Lomax', per_children = '<fg "m=123085961 ">Mary Ellen <i>Lomax</i> Campbell</fg>', per_timestamp = '2019-10-14 03:50:4' WHERE per_id = 12345

I can take the above query string and enter it into the MySQL table SQL form and it works with no problem.

Any help in either area will be greatly appreciated.

jdadwilson

--
James A Wilson
msgwcc@msholmes.org

Options: ReplyQuote


Subject
Written By
Posted
Double Insert
October 14, 2019 12:16AM
October 15, 2019 10:11AM
October 15, 2019 10:54AM
October 15, 2019 11:06AM
October 15, 2019 12:16PM
October 15, 2019 12:30PM
October 15, 2019 12:42PM
October 15, 2019 12:53PM
October 15, 2019 01:04PM
October 15, 2019 09:21PM
October 15, 2019 10:17PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.