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

(12-27-2015, 05:20 AM)pmbaldha Wrote:
(12-27-2015, 04:37 AM)pb.sajjad Wrote:
(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...
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?
Yes, right. 
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 
There is not error possibility minor error if we dump same database in live and same storage engine of database for live database. Moreover make sure that mysql version of development and production environment should be same to avoid performance related issue.
There is possible error in database connection due to wrong credential. I don't seem that there might be any transaction related error on live if everything is perfect in development environment.

If you found useful, please rate my answer or me.

Thanks a lot. Your explanation is good.
I think ever everything is good and do all validation, may be some error from server in order to insert or update database table.
Reply


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



Theme © iAndrew 2016 - Forum software by © MyBB