/**
* findOne can be called in several ways.
*
* Primary key mode: pass find() a single primary key, and it will return a
* single object matching that primary key.
*
* If you pass findOne() no arguments, the first object of this type will be
* returned.
*
* If you pass findOne() an associative array, it will be turned into a
* Horde_Rdo_Query object.
*
* If you pass findOne() a Horde_Rdo_Query, it will return the first object
* matching that query.
*/
public function findOne($arg = null)
{
if (is_null($arg)) {
$query = null;
} elseif (is_scalar($arg)) {
$query = array($this->primaryKey => $arg);
} else {
$query = $arg;
}
// Build a full Query object, and limit it to one result.
$query = Horde_Rdo_Query::create($query, $this);
$query->limit(1);
$list = new Horde_Rdo_List($query);
return $list->current();
}