当前位置: 首页>>代码示例>>PHP>>正文


PHP Column::isTemporalType方法代码示例

本文整理汇总了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;
    }
开发者ID:spryker,项目名称:Propel,代码行数:30,代码来源:QueryBuilder.php

示例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     */";
 }
开发者ID:SwissalpS,项目名称:Propel2,代码行数:24,代码来源:ObjectBuilder.php

示例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);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:18,代码来源:DefaultPlatform.php

示例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;
 }
开发者ID:rouffj,项目名称:Propel2,代码行数:42,代码来源:ObjectBuilder.php

示例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());
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:15,代码来源:ColumnTest.php


注:本文中的Propel\Generator\Model\Column::isTemporalType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。