Prado\Data\SqlMap\Configuration\TResultProperty::getPropertyValue PHP Метод

getPropertyValue() публичный Метод

Gets the value for the current property, converts to applicable type if necessary.
public getPropertyValue ( $registry, $row ) : mixed
Результат mixed property value.
    public function getPropertyValue($registry, $row)
    {
        $value = null;
        $index = $this->getColumnIndex();
        $name = $this->getColumn();
        if ($index > 0 && isset($row[$index])) {
            $value = $this->getTypedValue($registry, $row[$index]);
        } else {
            if (isset($row[$name])) {
                $value = $this->getTypedValue($registry, $row[$name]);
            }
        }
        if ($value === null && $this->getNullValue() !== null) {
            $value = $this->getTypedValue($registry, $this->getNullValue());
        }
        return $value;
    }

Usage Example

Пример #1
0
 /**
  * Apply the result to an object.
  * @param array a result set row retrieved from the database
  * @param object result object, array or list
  * @return object result filled with data.
  */
 protected function fillResultObjectProperty($row, $resultObject)
 {
     $index = 0;
     $registry = $this->getManager()->getTypeHandlers();
     foreach ($row as $k => $v) {
         $property = new TResultProperty();
         if (is_string($k) && strlen($k) > 0) {
             $property->setColumn($k);
         }
         $property->setColumnIndex(++$index);
         $type = gettype(TPropertyAccess::get($resultObject, $k));
         $property->setType($type);
         $value = $property->getPropertyValue($registry, $row);
         TPropertyAccess::set($resultObject, $k, $value);
     }
     return $resultObject;
 }