lithium\data\Collection::offsetExists PHP Method

offsetExists() public method

Returns a boolean indicating whether an offset exists for the current Collection.
public offsetExists ( string $offset ) : boolean
$offset string String or integer indicating the offset or index of an entity in the set.
return boolean Result.
    public function offsetExists($offset)
    {
        $this->offsetGet($offset);
        return array_key_exists($offset, $this->_data);
    }

Usage Example

Example #1
0
 /**
  * Checks to see if a record with the given index key is in the record set. If the record
  * cannot be found, and not all records have been loaded into the set, it will continue loading
  * records until either all available records have been loaded, or a matching key has been
  * found.
  *
  * @see lithium\data\collection\RecordSet::offsetGet()
  * @param mixed $offset The ID of the record to check for.
  * @return boolean Returns true if the record's ID is found in the set, otherwise false.
  */
 public function offsetExists($offset)
 {
     if (in_array($offset, $this->_index)) {
         return true;
     }
     return parent::offsetExists($offset);
 }