title: CodeIgniter - escape SQL statement
body: <p>I am programatically generating a SQL statement that I then need to execute, however it is failing, I think due to not being escaped properly.</p>
  
  <p>The SQL appears to be generated correctly in that I can cut and paste it from a browser and it executes correctly from the CMD line and PHPMyAdmin. Example:</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `1_e6766037c49ccf8cc3f8437c123d6e88` 
  (`intId` int(11) NOT NULL auto_increment,
  `twitter_retweet_count` TEXT NULL ,......
  </code></pre>
  
  <p>I then try to execute it using CI with:</p>
  
  <pre><code>$query = $this-&gt;db-&gt;query($sql);
  </code></pre>
  
  <p>However it fails with:</p>
  
  <pre><code>You have an error in your SQL syntax; check the manual that corresponds to your 
  MySQL server version for the right syntax to use near '
  `twitter_retweet_count` TEXT NULL ,.......
  </code></pre>
  
  <p>Any thoughts on where I might be going wrong?</p>
  
  <p>Many thanks, Ben.</p>