![]() ![]() ![]() Hello, thank you so much for this website. So it possible could be the reason why insert queries don't work. In case transactions are used, including db.php for the every query will actually roll back the previously executed query. It is not explained on this site because it's a database stuff while the site is PHP related. A transaction is not a synonym for executing an SQL query as you seemingly think. It's hard to tell actually.īy the look of it, it seems that somewhere in your code a transaction is started but never commited. BY NO MEANS db.php should be included for the every query. While config.php just gets included in db.php and none of our concern.Įither way, the point is, the connection should be made only once. And should be used the way was explained above: db.php should be included strictly ONCE on every page. It is made into a separate file so it will be the only file one has to edit moving the code to another server. $stmt = $pdo -> prepare ( "INSERT INTO users (name, surname, age) VALUES (?,?,?)" ) Ĭonfig.php is just integral part of db.php. So in the end our code would be like $data = [ In some circumstances it will greatly speed up the inserts, and it makes sense overall, to make sure that either all data has been added or none.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |