title: Codeigniter:Using defined constants for table names in a join call
body: <p>I have a defined constant for each of my database tables.</p>
  
  <pre><code>define('QTABLE','questions');
  define('ATABLE','answers');
  </code></pre>
  
  <p>I would like to join these tables using a commonly referenced column "xid".</p>
  
  <p>Here's how I'd do it if I referenced the actual name of the tables.</p>
  
  <pre><code>$this-&gt;db-&gt;from('questions');
  $this-&gt;db-&gt;select('qcount,answers.xid,answers.aval');
  $this-&gt;db-&gt;join('answers','questions.xid=answers.xid');
  $gquery=$this-&gt;db-&gt;get();
  </code></pre>
  
  <p>But I do not want to reference the table names directly in the code in case we need to rename them later. How would I use the defined constants correctly to do this with Codeigniter's Active Records? I suspect it's all about escaping with the correct kind of single/double quotes. </p>
  
  <p>I tried the following and it definitely does not work!</p>
  
  <pre><code>$this-&gt;db-&gt;from(Q-TABLE);
  $this-&gt;db-&gt;select('qcount,ATABLE.xid,ATABLE.aval'); &lt;----PROBLEM
  $this-&gt;db-&gt;join(ATABLE,'QTABLE.xid=ATABLE.xid');&lt;------PROBLEM
  $gquery=$this-&gt;db-&gt;get();
  </code></pre>
  
  <p>Could you show me the way to the light?</p>
  
  <p>mmiz</p>