title: mysql codeigniter active record m:m deletion
body: <p>I have a table 2 tables that have a m:m relationship, what I can wanting is that when I delete a row from one of the tables I want the row in the joining table to be deleted as well, my sql is as follow,</p>
  
  <p><strong>Table 1</strong></p>
  
  <pre><code>    CREATE TABLE IF NOT EXISTS `job_feed` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `body` text NOT NULL,
    `date_posted` int(10) NOT NULL,
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
  </code></pre>
  
  <p><strong>Table 2</strong></p>
  
  <pre><code>    CREATE TABLE IF NOT EXISTS `job_feed_has_employer_details` (
    `job_feed_id` int(11) NOT NULL,
    `employer_details_id` int(11) NOT NULL,
    PRIMARY KEY (`job_feed_id`,`employer_details_id`),
    KEY `fk_job_feed_has_employer_details_job_feed1` (`job_feed_id`),
    KEY `fk_job_feed_has_employer_details_employer_details1` (`employer_details_id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  </code></pre>
  
  <p>So what I am wanting to do is, if the a row is deleted from table1 and has an id of 1 I want the row in table to that also has that idea as part of the relationship also.</p>
  
  <p>I want to do this in keeping with codeigniters active record class I currently have this, </p>
  
  <pre><code>public function deleteJobFeed($feed_id)
      {
          $this-&gt;db-&gt;where('id', $feed_id)
                   -&gt;delete('job_feed');
  
          return $feed_id;
      }
  </code></pre>