title: setIntegrityCheck in Zend Selects with joins
body: <p>I was looking at <a href="https://stackoverflow.com/questions/2311481/how-to-use-join-in-zend-framework">some</a> <a href="https://stackoverflow.com/questions/3255466/how-can-i-join-tables-in-zend-while-using-a-class-that-inherits-from-zend-db-tab">questions</a> that ask how to do joins in Zend Framework queries, but the answer is always something like "just do <code>setIntegrityCheck(FALSE)</code>".</p>
  
  <p>My question is: <strong>why do I need to do this?</strong></p>
  
  <p>It seems to me disabling "integrity checks" is not the proper way of making this work. In my particular case, I'm using a MySQL database with some InnoDB tables with foreign keys, so for example:</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `tableA`
  (
  `id` CHAR(6),
  `name` VARCHAR(255),
  PRIMARY KEY (`id`)
  ) ENGINE=InnoDB;
  
  CREATE TABLE IF NOT EXISTS `tableB`
  (
  `tableA_id` CHAR(6),
  `somefield` VARCHAR(255),
  PRIMARY KEY (`tableA_id`)
  ) ENGINE=InnoDB;
  
  ALTER TABLE `tableB` ADD FOREIGN KEY fk1 (`tableA_id`) REFERENCES `tableA` (`id`);
  </code></pre>
  
  <p>(this is a very simplified version of my DB)</p>
  
  <p>And, my query code looks like this:</p>
  
  <pre><code>$table = new Zend_Db_Table('tableB');
  $select = $table-&gt;select(TRUE)
    -&gt;join(array('a' =&gt; 'tableA'), 'tableB.tableA_id = a.id');
  $result = $table-&gt;fetchAll($select);
  </code></pre>
  
  <p>This is giving me the <em>"Select query cannot join with another table"</em> exception unless I add the <code>setIntegrity(FALSE)</code> to my <code>$select</code>.</p>