Spot\Query::first PHP Method

first() public method

Return the first entity matched by the query
public first ( ) : mixed
return mixed Spot_Entity on success, boolean false on failure
    public function first()
    {
        $result = $this->limit(1)->execute();
        return $result !== false ? $result->first() : false;
    }

Usage Example

Esempio n. 1
0
 /**
  * Get the relation entity
  * @return \Spot\Entity\EntityInterface
  */
 public function entity()
 {
     if (null === $this->entity) {
         $this->entity = $this->execute();
         if ($this->entity instanceof Query) {
             $this->entity = $this->entity->first();
         } else {
             if ($this->entity instanceof ResultsetInterface) {
                 $this->entity = $this->entity->first();
             }
         }
     }
     return $this->entity;
 }