本文整理汇总了PHP中Propel\Generator\Model\Column::isTemporalType方法的典型用法代码示例。如果您正苦于以下问题:PHP Column::isTemporalType方法的具体用法?PHP Column::isTemporalType怎么用?PHP Column::isTemporalType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Generator\Model\Column
的用法示例。
在下文中一共展示了Column::isTemporalType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFilterByColBetween
protected function addFilterByColBetween(Column $col)
{
$script = '';
if ($col->isNumericType() || $col->isTemporalType()) {
$colPhpName = $col->getPhpName();
$variableName = $col->getCamelCaseName();
$queryClassName = $this->getQueryClassName();
$script .= <<<SCRIPT
/**
* Applies SprykerCriteria::BETWEEN filtering criteria for the column.
*
* @param array \${$variableName} Filter value.
* [
* 'min' => 3, 'max' => 5
* ]
*
* 'min' and 'max' are optional, when neither is specified, throws \\Spryker\\Zed\\Propel\\Business\\Exception\\AmbiguousComparisonException.
*
* @return \$this|{$queryClassName} The current query, for fluid interface
*/
public function filterBy{$colPhpName}_Between(array \${$variableName})
{
return \$this->filterBy{$colPhpName}(\${$variableName}, SprykerCriteria::BETWEEN);
}
SCRIPT;
}
return $script;
}
示例2: addColumnAttributeComment
/**
* Adds comment about the attribute (variable) that stores column values.
*
* @param string &$script
* @param Column $column
*/
protected function addColumnAttributeComment(&$script, Column $column)
{
if ($column->isTemporalType()) {
$cptype = $this->getDateTimeClass($column);
} else {
$cptype = $column->getPhpType();
}
$clo = $column->getLowercasedName();
$script .= "\n /**\n * The value for the {$clo} field.\n * " . $column->getDescription();
if ($column->getDefaultValue()) {
if ($column->getDefaultValue()->isExpression()) {
$script .= "\n * Note: this column has a database default value of: (expression) " . $column->getDefaultValue()->getValue();
} else {
$script .= "\n * Note: this column has a database default value of: " . $this->getDefaultValueString($column);
}
}
$script .= "\n * @var {$cptype}\n */";
}
示例3: getColumnBindingPHP
/**
* Get the PHP snippet for binding a value to a column.
* Warning: duplicates logic from AdapterInterface::bindValue().
* Any code modification here must be ported there.
*/
public function getColumnBindingPHP(Column $column, $identifier, $columnValueAccessor, $tab = " ")
{
$script = '';
if ($column->isTemporalType()) {
$columnValueAccessor = $columnValueAccessor . " ? " . $columnValueAccessor . "->format(\"" . $this->getTimeStampFormatter() . "\") : null";
} elseif ($column->isLobType()) {
// we always need to make sure that the stream is rewound, otherwise nothing will
// get written to database.
$script .= "\nif (is_resource({$columnValueAccessor})) {\n rewind({$columnValueAccessor});\n}";
}
$script .= sprintf("\n\$stmt->bindValue(%s, %s, %s);", $identifier, $columnValueAccessor, PropelTypes::getPdoTypeString($column->getType()));
return preg_replace('/^(.+)/m', $tab . '$1', $script);
}
示例4: getDefaultValueString
/**
* Returns the type-casted and stringified default value for the specified Column.
* This only works for scalar default values currently.
* @return string The default value or 'NULL' if there is none.
*/
protected function getDefaultValueString(Column $col)
{
$defaultValue = var_export(null, true);
$val = $col->getPhpDefaultValue();
if ($val === null) {
return $defaultValue;
}
if ($col->isTemporalType()) {
$fmt = $this->getTemporalFormatter($col);
try {
if (!($this->getPlatform() instanceof MysqlPlatform && ($val === '0000-00-00 00:00:00' || $val === '0000-00-00'))) {
// while technically this is not a default value of NULL,
// this seems to be closest in meaning.
$defDt = new DateTime($val);
$defaultValue = var_export($defDt->format($fmt), true);
}
} catch (Exception $x) {
// prevent endless loop when timezone is undefined
date_default_timezone_set('America/Los_Angeles');
throw new EngineException(sprintf('Unable to parse default temporal value "%s" for column "%s"', $col->getDefaultValueString(), $col->getFullyQualifiedName()), $x);
}
} elseif ($col->isEnumType()) {
$valueSet = $col->getValueSet();
if (!in_array($val, $valueSet)) {
throw new EngineException(sprintf('Default Value "%s" is not among the enumerated values', $val));
}
$defaultValue = array_search($val, $valueSet);
} elseif ($col->isPhpPrimitiveType()) {
settype($val, $col->getPhpType());
$defaultValue = var_export($val, true);
} elseif ($col->isPhpObjectType()) {
$defaultValue = 'new ' . $col->getPhpType() . '(' . var_export($val, true) . ')';
} else {
throw new EngineException("Cannot get default value string for " . $col->getFullyQualifiedName());
}
return $defaultValue;
}
示例5: testTemporalType
/**
* @dataProvider provideMappingTemporalTypes
*/
public function testTemporalType($mappingType)
{
$domain = $this->getDomainMock();
$domain->expects($this->once())->method('setType')->with($this->equalTo($mappingType));
$domain->expects($this->any())->method('getType')->will($this->returnValue($mappingType));
$column = new Column();
$column->setDomain($domain);
$column->setType($mappingType);
$this->assertSame('string', $column->getPhpType());
$this->assertTrue($column->isPhpPrimitiveType());
$this->assertTrue($column->isTemporalType());
}