SwatDB/SwatDBDataObject.php
protected function initFromRow($row)
    {
        if ($row === null) {
            throw new SwatDBException(
                'Attempting to initialize dataobject with a null row.'
            );
        }

        $property_array = array_merge(
            $this->getPublicProperties(),
            $this->getSerializableProtectedProperties()
        );

        if (is_object($row)) {
            $row = get_object_vars($row);
        }

        foreach ($property_array as $name => $value) {
            // Use array_key_exists() instead of isset(), because isset() will
            // return false when the value is null. Null values on properties
            // should not be ignored - otherwise calling initFromRow() on an
            // existing dataobject can leave out of date values on properties
            // when those values were updated to null.
            if (array_key_exists($name, $row)) {
                if (
                    in_array($name, $this->date_properties) &&
                    $row[$name] !== null
                ) {
                    $this->$name = new SwatDate($row[$name]);
                } else {
                    $this->$name = $row[$name];
                }
            }
        }

        foreach ($this->internal_properties as $name => $value) {
            if (isset($row[$name])) {
                $this->internal_properties[$name] = $row[$name];
            }
        }

        $this->loaded_from_database = true;
    }
protected function initFromRow($row)
    {
        if ($row === null) {
            throw new SwatDBException(
                'Attempting to initialize dataobject with a null row.'
            );
        }

        $property_array = array_merge(
            $this->getPublicProperties(),
            $this->getSerializableProtectedProperties()
        );

        if (is_object($row)) {
            $row = get_object_vars($row);
        }

        foreach ($property_array as $name => $value) {
            // Use array_key_exists() instead of isset(), because isset() will
            // return false when the value is null. Null values on properties
            // should not be ignored - otherwise calling initFromRow() on an
            // existing dataobject can leave out of date values on properties
            // when those values were updated to null.
            if (array_key_exists($name, $row)) {
                if (
                    in_array($name, $this->date_properties) &&
                    $row[$name] !== null
                ) {
                    $this->$name = new SwatDate($row[$name]);
                } else {
                    $this->$name = $row[$name];
                }
            }
        }

        foreach ($this->internal_properties as $name => $value) {
            if (isset($row[$name])) {
                $this->internal_properties[$name] = $row[$name];
            }
        }

        $this->loaded_from_database = true;
    }
protected function initFromRow ( $ row ) { if ( $ row === null ) { throw new SwatDBException ( 'Attempting to initialize dataobject with a null row.' ) ; } $ property_array = array_merge ( $ this -> getPublicProperties ( ) , $ this -> getSerializableProtectedProperties ( ) ) ; if ( is_object ( $ row ) ) { $ row = get_object_vars ( $ row ) ; } foreach ( $ property_array as $ name => $ value ) { // Use array_key_exists() instead of isset(), because isset() will // return false when the value is null. Null values on properties // should not be ignored - otherwise calling initFromRow() on an // existing dataobject can leave out of date values on properties // when those values were updated to null. if ( array_key_exists ( $ name , $ row ) ) { if ( in_array ( $ name , $ this -> date_properties ) && $ row [ $ name ] !== null ) { $ this -> $ name = new SwatDate ( $ row [ $ name ] ) ; } else { $ this -> $ name = $ row [ $ name ] ; } } } foreach ( $ this -> internal_properties as $ name => $ value ) { if ( isset ( $ row [ $ name ] ) ) { $ this -> internal_properties [ $ name ] = $ row [ $ name ] ; } } $ this -> loaded_from_database = true ; }
Takes a data row and sets the properties of this object according to
the values of the row

Subclasses can override this method to provide additional
functionality.

@param mixed $row the row to use as either an array or object.
Takes a data row and sets the properties of this object according to the values of the row