title: CakePHP 1.3 exists($id) function examples/how to
body: <p>Is there an exists($id) function for cakephp 1.3 to see if a record exists in a table? I have a database which is synced from another server. My database has 2 tables, the synced table, and one i've put in to expand on the synced table. My app right now lists all the items in the primary(synced) table and when they click that item it takes them to a view to add information that's different to the second table. It passes the ID to the second table. </p>
  
  <p>What I want to do is check the second table first, to see if the record with the corresponding foreign key exists, if it does, then move to the edit screen for that record in the second table, if not, I want to make sure the record exists in the first table and if it does, add a record to the second table with the given $id as the foreign key.</p>
  
  <p>Thinking about it now, it passes the correct id to the second table, I just don't want the user to be able to type a number and assume it exists in the primary table and add a record to the second table, which doesn't actually exist. If there's not a function to check that, could I use the association to check? Like:</p>
  
  <pre><code>if (!$this-&gt;Table2-&gt;Table1-&gt;id) {
      //if id does not exist in parent table don't create the record in the second table and print an error
  } else {
      //id does exist in parent table either add a new record with the foreign key being the id passed from parent or redirect to edit screen for that record in second table
  }
  </code></pre>