I am currently working on a project which will have so many queries run a same time. and I am sending data to database in one table and want to check if the data is successfully inserted. I read about mysql_affected_rows(); function and that it will return the values but for example I will have approx 100 tables and as by user going to use my application it will sending data to different table at same times. so the question is how do mysql_affected_rows() will work. because at a same time its gonna be multiple queries in different table. as mysql_affected_rows will need only database connection and it will return the last updation in the database.
how do I can check the data update on the table which I want to check.
example I have a table name user_info. I want to see if data is inserted successfully in the table or not. as mysql_affected_rows() will return the last database updation as it doesn’t matter on which table. it will return the database updatation. but in mean while if some else query hit the database and mysql_affected_rows will return the query as succesfull.
I hope my question is clear.
2
Answers
Its done with the Error handling if its not returning any error yes its added to database
If you are using
AUTO_INCREMENT
with your column, then you can uselast_insert_id()
method. This method gets the ID of the last inserted record in MySQL. Insert some records in the table using insert command. Display all records from the table using select statement.