title: Kohana 3.2 ORM Check the existence of a single record
body: <p>I'm having a bit of trouble trying to figure out the best way to check if a particular result contains any records for the following code:</p>
  
  <pre><code> $record = ORM::factory('my_table', $id);
  </code></pre>
  
  <p>What I would normally do is use a counter method like $record->count() or  $records->exist() method that would simply return true or false if anything was found. But there is not such a thing implemented for ORM. </p>
  
  <p>I know kohana ORMs implements the SPL countable interface therefore I can use the php count() function, but this is really not useful when only one record is expected because count() will return 1 for any model that contains no data, for example if an id was not found. </p>
  
  <p>This is the way I get around it:</p>
  
  <pre><code>try {
   $record = ORM::factory('my_table', $id);
  
   if($record-&gt;id === NULL) {
     throw new Exception('The id: ' . $id . ' was not found, use a valid ID');
   }
  </code></pre>
  
  <p>}</p>
  
  <p>This particular solution is not very good, what if my the table doesn't contain an id field or if the table allows IDs to be null? </p>
  
  <p>There has to be a better way to check if a model contains any data or not.  </p>
  
  <p>Any ideas?</p>