I’m just curious as to what your opinion is regarding performing a query such as this:
INSERT INTO table SET id = '1' AND live = ' . $live . '
verses this
INSERT INTO table SET id = 1 AND live = 1
Personally the omission of single quotes makes more sense to me as the value being entered is an integer type, so it would seem bad practice (even though it works) to send it to the database as a string.
I realise there are certain benefits to the first query such as the fact that if by some chance the $live field was not set then it would no error as the query string would remain intact, however I feel this should be thought of in the error checking.
Does anyone else have any opinion and care to share their thoughts?
I was not aware of this and is something I’ve often thought about but never investigated. I’ll have to make an effort to change my habits to using INSERT VALUES from now on.