When to use ' ' vs ` ` ?

TheBigK

Well-known member
I'm not sure how to describe this. But here's a code from my datawriter that was throwing error "The field sf_id is not recognised'. I had to change the `sf_id` to 'sf_id'

'sf_id' => array('type' => self::TYPE_UINT, 'autoIncrement' => true),

I've seen that many times while writing SQL queries, I must use `something` over 'something'. Can someone point out the difference?
 
That isn't a query, you should use ` in queries around table/field names, not in array keys :)
 
` (backtick) is pretty much used exclusively to escape column and table names in MySQL.
' (single quote) is used to enclose strings in PHP and MySQL. In most cases you can also use " (double quote)
 
Back
Top Bottom