/** * Set column value from instance. * * @param \BaseObject $instance * @param \ColumnMap $column * @param mixed $value */ protected function setColumnValue(\BaseObject $instance, \ColumnMap $column, $value) { if ($column->getType() === \PropelColumnTypes::PHP_ARRAY && !is_array($value)) { if (is_string($value) && !empty($value)) { $value = explode("\n", $value); } else { if ($value !== null) { $value = array(); } } } $instance->{'set' . $column->getPhpName()}($value); }
/** * Get value for column to use in database dump. * * @param BaseObject $obj * @param ColumnMap $column * @return mixed */ protected static function getColumnValue(BaseObject $obj, ColumnMap $column) { switch ($column->getType()) { case PropelColumnTypes::DATE: return $obj->{'get' . $column->getPhpName()}('Y-m-d'); break; case PropelColumnTypes::TIMESTAMP: return $obj->{'get' . $column->getPhpName()}('Y-m-d H:i:s'); break; case PropelColumnTypes::TIME: return $obj->{'get' . $column->getPhpName()}('H:i:s'); break; default: return $obj->{'get' . $column->getPhpName()}(); } }
/** * Extract the value method and the required parameters for it, for given a ColumnMap's type. * Return an Array holding the value method as first value and its parameters as the second one. * * @param ColumnMap $column * @return Array */ public static function extractValueMethod(ColumnMap $column) { $value_method = 'get' . $column->getPhpName(); $params = null; if (in_array($column->getType(), array(PropelColumnTypes::BU_DATE, PropelColumnTypes::DATE))) { $params = ncChangeLogConfigHandler::getDateFormat(); } elseif (in_array($column->getType(), array(PropelColumnTypes::BU_TIMESTAMP, PropelColumnTypes::TIMESTAMP))) { $params = ncChangeLogConfigHandler::getDateTimeFormat(); } elseif ($column->getType() == PropelColumnTypes::TIME) { $params = ncChangeLogConfigHandler::getTimeFormat(); } return array($value_method, $params); }