Pheasant::instance PHP Method

instance() public static method

Returns the static Pheasant instance
public static instance ( ) : Pheasant
return Pheasant
    public static function instance()
    {
        return self::$_instance;
    }

Usage Example

Example #1
0
 public function get($object, $key, $cache = null)
 {
     if ($cache) {
         $schema = \Pheasant::instance()->schema($this->class);
         if ($cached = $cache->get($schema->hash($object, array(array($this->local, $this->foreign))))) {
             return $cached;
         }
     }
     if (($localValue = $object->{$this->local}) === null) {
         if ($this->_allowEmpty) {
             return null;
         } else {
             throw new \Pheasant\Exception("Local value is null while not allowed");
         }
     }
     $result = $this->query("{$this->foreign}=?", $localValue)->execute();
     if (!count($result)) {
         if ($this->_allowEmpty) {
             return null;
         } else {
             throw new \Pheasant\Exception("Failed to find a {$key} (via {$this->foreign}={$localValue})");
         }
     }
     return $this->hydrate($result->row());
 }
All Usage Examples Of Pheasant::instance