Welcome Guest, Not a member yet? Register   Sign In
Insert and Update database checking
#5

(12-27-2015, 01:27 AM)pmbaldha Wrote:
(12-26-2015, 12:14 PM)pb.sajjad Wrote: Hello...
I'm using CI3 and its query builders. I want know if I insert (or update) some data into tables, should I check insert (or update) result (to sure about operation)? In fact, is there some situation that MySQL does not insert or update? What is these reasons?
thanks...

You can know inserted or updated performed of not by
$this->db->affected_rows();
if affected rows are greater than zero, insert or update operation is affected.

-----------------------------------------------------------------------------------------------------
 is there some situation that MySQL does not insert or update? What is these reasons?
In development environment error reporting is on, so if any error occurred in insert or update query, webpage will throw error. in dev environment, error reporting is on.
But in production environment, if any error occured in sql query then you will not be notified and there is possibility that you insert (or update) will not affected at db level and still you are not aware of it.

Generally, We are developing code in dev environment and make fully testing and then we are moving code to production environment, so logically this situation is not possible but technically this situation is possible if you are directly coding in production environment.

To understand codeigniter environment, please visit https://www.codeigniter.com/user_guide/g...ments.html

Thanks for replying...
Your're right, and I know about $this->db->affected_rows(); . I've already read codeigniter different environment.
So, as your explanation, if I test everything in development environment and everything will be correct, there is no need to check insert/update result. Is this true?
Is it possible that everything is correct in development environment, but in live server and in production environment, an error will be occured (MySQL do not operate correctly) ? For example, after user registering, user info does not insert, or after editing info, update row encounter with errors (assume that I validate all info and...). Or about transactions or...
Reply


Messages In This Thread
RE: Insert and Update database checking - by pb.sajjad - 12-27-2015, 04:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB