src/xPDO/Om/xPDOObject.php
public function fromArray($fldarray, $keyPrefix= '', $setPrimaryKeys= false, $rawValues= false, $adhocValues= false) {
        if (is_array($fldarray)) {
            $pkSet= false;
            $generatedKey= false;
            foreach ($fldarray as $key => $val) {
                if (!empty ($keyPrefix)) {
                    $prefixPos= strpos($key, $keyPrefix);
                    if ($prefixPos === 0) {
                        $key= substr($key, strlen($keyPrefix));
                    } else {
                        continue;
                    }
                    if ($this->xpdo->getDebug() === true) $this->xpdo->log(xPDO::LOG_LEVEL_DEBUG, "Stripped prefix {$keyPrefix} to produce key {$key}");
                }
                $key = $this->getField($key);
                if (isset ($this->_fieldMeta[$key]['index']) && $this->_fieldMeta[$key]['index'] == 'pk') {
                    if ($setPrimaryKeys) {
                        if (isset ($this->_fieldMeta[$key]['generated'])) {
                            $generatedKey= true;
                        }
                        if ($this->_new) {
                            if ($rawValues || $generatedKey) {
                                $this->_setRaw($key, $val);
                            } else {
                                $this->set($key, $val);
                            }
                            $pkSet= true;
                        }
                    }
                }
                elseif (isset ($this->_fieldMeta[$key])) {
                    if ($rawValues) {
                        $this->_setRaw($key, $val);
                    } else {
                        $this->set($key, $val);
                    }
                }
                elseif ($adhocValues || $this->getOption(xPDO::OPT_HYDRATE_ADHOC_FIELDS)) {
                    if ($rawValues) {
                        $this->_setRaw($key, $val);
                    } else {
                        $this->set($key, $val);
                    }
                }
                if ($this->isLazy($key)) {
                    $this->_lazy = array_diff($this->_lazy, array($key));
                }
            }
        }
    }
public function fromArray($fldarray, $keyPrefix= '', $setPrimaryKeys= false, $rawValues= false, $adhocValues= false) {
        if (is_array($fldarray)) {
            $pkSet= false;
            $generatedKey= false;
            foreach ($fldarray as $key => $val) {
                if (!empty ($keyPrefix)) {
                    $prefixPos= strpos($key, $keyPrefix);
                    if ($prefixPos === 0) {
                        $key= substr($key, strlen($keyPrefix));
                    } else {
                        continue;
                    }
                    if ($this->xpdo->getDebug() === true) $this->xpdo->log(xPDO::LOG_LEVEL_DEBUG, "Stripped prefix {$keyPrefix} to produce key {$key}");
                }
                $key = $this->getField($key);
                if (isset ($this->_fieldMeta[$key]['index']) && $this->_fieldMeta[$key]['index'] == 'pk') {
                    if ($setPrimaryKeys) {
                        if (isset ($this->_fieldMeta[$key]['generated'])) {
                            $generatedKey= true;
                        }
                        if ($this->_new) {
                            if ($rawValues || $generatedKey) {
                                $this->_setRaw($key, $val);
                            } else {
                                $this->set($key, $val);
                            }
                            $pkSet= true;
                        }
                    }
                }
                elseif (isset ($this->_fieldMeta[$key])) {
                    if ($rawValues) {
                        $this->_setRaw($key, $val);
                    } else {
                        $this->set($key, $val);
                    }
                }
                elseif ($adhocValues || $this->getOption(xPDO::OPT_HYDRATE_ADHOC_FIELDS)) {
                    if ($rawValues) {
                        $this->_setRaw($key, $val);
                    } else {
                        $this->set($key, $val);
                    }
                }
                if ($this->isLazy($key)) {
                    $this->_lazy = array_diff($this->_lazy, array($key));
                }
            }
        }
    }
public function fromArray ( $ fldarray , $ keyPrefix = '' , $ setPrimaryKeys = false , $ rawValues = false , $ adhocValues = false ) { if ( is_array ( $ fldarray ) ) { $ pkSet = false ; $ generatedKey = false ; foreach ( $ fldarray as $ key => $ val ) { if ( ! empty ( $ keyPrefix ) ) { $ prefixPos = strpos ( $ key , $ keyPrefix ) ; if ( $ prefixPos === 0 ) { $ key = substr ( $ key , strlen ( $ keyPrefix ) ) ; } else { continue ; } if ( $ this -> xpdo -> getDebug ( ) === true ) $ this -> xpdo -> log ( xPDO :: LOG_LEVEL_DEBUG , "Stripped prefix {$keyPrefix} to produce key {$key}" ) ; } $ key = $ this -> getField ( $ key ) ; if ( isset ( $ this -> _fieldMeta [ $ key ] [ 'index' ] ) && $ this -> _fieldMeta [ $ key ] [ 'index' ] == 'pk' ) { if ( $ setPrimaryKeys ) { if ( isset ( $ this -> _fieldMeta [ $ key ] [ 'generated' ] ) ) { $ generatedKey = true ; } if ( $ this -> _new ) { if ( $ rawValues || $ generatedKey ) { $ this -> _setRaw ( $ key , $ val ) ; } else { $ this -> set ( $ key , $ val ) ; } $ pkSet = true ; } } } elseif ( isset ( $ this -> _fieldMeta [ $ key ] ) ) { if ( $ rawValues ) { $ this -> _setRaw ( $ key , $ val ) ; } else { $ this -> set ( $ key , $ val ) ; } } elseif ( $ adhocValues || $ this -> getOption ( xPDO :: OPT_HYDRATE_ADHOC_FIELDS ) ) { if ( $ rawValues ) { $ this -> _setRaw ( $ key , $ val ) ; } else { $ this -> set ( $ key , $ val ) ; } } if ( $ this -> isLazy ( $ key ) ) { $ this -> _lazy = array_diff ( $ this -> _lazy , array ( $ key ) ) ; } } } }
Sets object fields from an associative array of key => value pairs.

@param array $fldarray An associative array of key => values.
@param string $keyPrefix Specify an optional prefix to strip from all array
keys in fldarray.
@param boolean $setPrimaryKeys Optional param to set generated primary keys.
@param boolean $rawValues Optional way to set values without calling the
{@link xPDOObject::set()} method.
@param boolean $adhocValues Optional way to set adhoc values so that all the values of
fldarray become object vars.
Sets object fields from an associative array of key = > value pairs .