/** * Apply result mapping. * @param array a result set row retrieved from the database * @param object the result object, will create if necessary. * @return object the result filled with data, null if not filled. */ protected function applyResultMap($row, &$resultObject = null) { if ($row === false) { return null; } $resultMapName = $this->_statement->getResultMap(); $resultClass = $this->_statement->getResultClass(); $obj = null; if ($this->getManager()->getResultMaps()->contains($resultMapName)) { $obj = $this->fillResultMap($resultMapName, $row, null, $resultObject); } else { if (strlen($resultClass) > 0) { $obj = $this->fillResultClass($resultClass, $row, $resultObject); } else { $obj = $this->fillDefaultResultMap(null, $row, $resultObject); } } if (class_exists('TActiveRecord', false) && $obj instanceof TActiveRecord) { //Create a new clean active record. $obj = TActiveRecord::createRecord(get_class($obj), $obj); } return $obj; }
/** * @param string active record class name. * @param array row data * @param array foreign key column names * @return TActiveRecord */ protected function createFkObject($type, $row, $foreignKeys) { $obj = TActiveRecord::createRecord($type, $row); if (count($this->_association_columns) > 0) { $i = 0; foreach ($foreignKeys as $ref => $fk) { $obj->setColumnValue($ref, $row[$this->_association_columns[$i++]]); } } return $obj; }