title: Doctrine: Query only where relationship doesn't exist?
body: <p>I have two tables: Articles and Categories. Articles can have a single Category assigned to them. But they don't have to have a Category.</p>
  
  <p>Schema:</p>
  
  <pre><code>Article:
    columns:
      title:
        type: string(255)
      content:
        type: string(255)
      category_id:
        type: integer(4)
  
  Category:
    columns:
      name:
        type: string(255)
      article_id:
        type: integer(4)
    relations:
      Article:
        class: Article
        local: article_id
        foreign: id
        foreignAlias: ArticleCategories
  </code></pre>
  
  <p>I can query for all Articles that have categories assigned to them like this:</p>
  
  <pre><code>$articles= Doctrine_Query::create()
    -&gt;from('Article a')
    -&gt;leftJoin('a.Category c ON c.article_id = a.id')
    -&gt;where('c.id &gt; 0')
    -&gt;execute();
  </code></pre>
  
  <p>It returns this:</p>
  
  <pre><code>Object-&gt;Array
  (
    [0] =&gt; Array
    (
      [id] =&gt; string(1) "1"
      [title] =&gt; string(4) "test"
      [content] =&gt; string(4) "test"
      [Category] =&gt; Array
      (
        [0] =&gt; Array
        (
          [id] =&gt; string(1) "2"
          [name] =&gt; string(7) "testing"
        )
      )
    )
  etc...
  </code></pre>
  
  <p>What I need to do is query for Articles where there is no Category relationship. I can't just say <code>-&gt;where('c.id = NULL')</code> either because if there is no Category relationship, then there isn't any <code>[Category]</code> array returned in the object. It only returns the <code>id, title and content</code>. Also I can't say <code>-&gt;where(a.Category = NULL)</code> because Category isn't a column of Article.</p>
  
  <p>Any ideas?</p>
  
  <p><strong>UPDATE</strong>
  I made a mistake on the Schema and updated it. I know it doesn't really make sense for an Category to only have a relationship with a single Article, but in reality I'm not using Articles/Categories. I was just using those terms as examples.</p>