本文整理汇总了PHP中ColumnMap::getValueSet方法的典型用法代码示例。如果您正苦于以下问题:PHP ColumnMap::getValueSet方法的具体用法?PHP ColumnMap::getValueSet怎么用?PHP ColumnMap::getValueSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ColumnMap
的用法示例。
在下文中一共展示了ColumnMap::getValueSet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getWidgetOptionsForColumn
/**
* Returns a PHP string representing options to pass to a widget for a given column.
*
* @param ColumnMap $column A ColumnMap object
*
* @return string The options to pass to the widget as a PHP string
*/
public function getWidgetOptionsForColumn(ColumnMap $column)
{
$options = array();
$withEmpty = $column->isNotNull() && !$column->isForeignKey() ? array("'with_empty' => false") : array();
switch ($column->getType()) {
case PropelColumnTypes::BOOLEAN:
case PropelColumnTypes::BOOLEAN_EMU:
$options[] = "'choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no')";
break;
case PropelColumnTypes::DATE:
case PropelColumnTypes::TIME:
case PropelColumnTypes::TIMESTAMP:
$options[] = "'from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate()";
$options = array_merge($options, $withEmpty);
break;
case PropelColumnTypes::ENUM:
$valueSet = $column->getValueSet();
$choices = array_merge(array('' => 'all'), $valueSet);
$options[] = sprintf("'choices' => %s", preg_replace('/\\s+/', '', var_export($choices, true)));
break;
default:
$options = array_merge($options, $withEmpty);
}
if ($column->isForeignKey()) {
$options[] = sprintf('\'model\' => \'%s\', \'add_empty\' => true', $this->getForeignTable($column)->getClassname());
$refColumn = $this->getForeignTable($column)->getColumn($column->getRelatedColumnName());
if (!$refColumn->isPrimaryKey()) {
$options[] = sprintf('\'key_method\' => \'get%s\'', $refColumn->getPhpName());
}
}
return count($options) ? sprintf('array(%s)', implode(', ', $options)) : '';
}
示例2: _getColumnRawValue
protected static function _getColumnRawValue(ColumnMap $column, $value)
{
if ($value === null) {
return null;
}
switch ($column->getType()) {
case PropelColumnTypes::ENUM:
$valueSet = $column->getValueSet();
return array_search($value, $valueSet);
case PropelColumnTypes::PHP_ARRAY:
return '| ' . implode(' | ', $value) . ' |';
case PropelColumnTypes::OBJECT:
return serialize($value);
}
return $value;
}