title: MySQL Queries using Doctrine & CodeIgniter
body: <p>EDIT: The reason why my Doctrine queries (see below) did not work/produced those errors was because I left out</p>
  
  <blockquote>
    <p>ci_doctrine.</p>
  </blockquote>
  
  <p>when creating this database: </p>
  
  <pre><code>CREATE TABLE `ci_doctrine`.`user` (
      `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
      `username` VARCHAR( 255 ) NOT NULL ,
      `password` VARCHAR( 255 ) NOT NULL ,
      `first_name` VARCHAR( 255 ) NOT NULL ,
      `last_name` VARCHAR( 255 ) NOT NULL ,
      UNIQUE (`username`
  )
  )
  </code></pre>
  
  <p>END OF EDIT</p>
  
  <p>How do I write plane SQL queries using Doctrine connection object and display the results? For example, how do I perform:</p>
  
  <pre><code>SELECT * FROM table_name WHERE column_name LIKE '%anything_similar_to_this%';
  </code></pre>
  
  <p>using Doctrine something like this (this example does not work)</p>
  
  <pre><code> $search_key = 'search_for_this';
  
   $conn = Doctrine_Manager::connection();
  
   $conn-&gt;execute('SELECT * FROM table_name WHERE column_name LIKE ?)',  $search_key);
  
   echo $conn;  
  </code></pre>
  
  <p>I've also tried:</p>
  
  <pre><code>$search_key = 2;
  $q = new Doctrine_RawSql();
  $result = $q-&gt;select('column_name')
    -&gt;from('table_name')
    -&gt;where('id = ?', $search_key)
    -&gt;execute();
  
  echo $result;
  </code></pre>