/** * Find rows in the rowset based on a needle * * This functions accepts either a know position or associative array of key/value pairs * * @param string|array $needle The position or the key or an associative array of column data to match * @return DatabaseRowsetInterface Returns a rowset if successful. Otherwise NULL. */ public function find($needle) { //Filter the objects $objects = $this->__rowset->filter(function ($object) use($needle) { if (is_array($needle)) { foreach ($needle as $key => $value) { if (!in_array($object->getProperty($key), (array) $value)) { return false; } } } else { return (bool) ($object->getHandle() == $needle); } }); $result = false; if (is_array($needle) || count($objects)) { //Create the entities $result = clone $this; $result->clear(); //Create the resultset foreach ($objects as $object) { $result->insert($object); } } return $result; }