1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

When to use ' ' vs ` ` ?

Discussion in 'XenForo Development Discussions' started by TheBigK, Aug 3, 2015.

  1. TheBigK

    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?
  2. Jake B.

    Jake B. Well-Known Member

    That isn't a query, you should use ` in queries around table/field names, not in array keys :)
  3. Chris D

    Chris D XenForo Developer Staff Member

    ` (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)
  4. TheBigK

    TheBigK Well-Known Member

  5. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    TheBigK likes this.

Share This Page