LeanMapper\Entity::getReflection PHP Метод

getReflection() публичный статический Метод

Gets reflection of current entity
public static getReflection ( leanmapper\IMapper $mapper = null ) : EntityReflection
$mapper leanmapper\IMapper
Результат LeanMapper\Reflection\EntityReflection
    public static function getReflection(IMapper $mapper = null)
    {
        $class = get_called_class();
        $mapperClass = $mapper !== null ? get_class($mapper) : '';
        if (!isset(static::$reflections[$class][$mapperClass])) {
            static::$reflections[$class][$mapperClass] = new EntityReflection($class, $mapper);
        }
        return static::$reflections[$class][$mapperClass];
    }

Usage Example

Пример #1
0
 /**
  * @param Entity $entity
  * @return \DibiResult|int
  */
 protected function updateInDatabase(Entity $entity)
 {
     $primaryKey = $this->mapper->getPrimaryKey($this->getTable());
     $idField = $this->mapper->getEntityField($this->getTable(), $primaryKey);
     $values = $entity->getModifiedRowData();
     $this->changeEmptyStringsToNull($values, $entity->getReflection()->getEntityProperties());
     return $this->connection->query('UPDATE %n SET %a WHERE %n = ?', $this->getTable(), $values, $primaryKey, $entity->{$idField});
 }