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


PHP Column::getType方法代码示例

本文整理汇总了PHP中Propel\Generator\Model\Column::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP Column::getType方法的具体用法?PHP Column::getType怎么用?PHP Column::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Propel\Generator\Model\Column的用法示例。


在下文中一共展示了Column::getType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addTranslatedColumnSetter

 protected function addTranslatedColumnSetter(Column $column)
 {
     $visibility = $column->getTable()->isReadOnly() ? 'protected' : $column->getMutatorVisibility();
     $typeHint = '';
     $null = '';
     if ($column->getTypeHint()) {
         $typeHint = $column->getTypeHint();
         if ('array' !== $typeHint) {
             $typeHint = $this->declareClass($typeHint);
         }
         $typeHint .= ' ';
         if (!$column->isNotNull()) {
             $null = ' = null';
         }
     }
     $typeHint = "{$typeHint}\$v{$null}";
     $i18nTablePhpName = $this->builder->getClassNameFromBuilder($this->builder->getNewStubObjectBuilder($this->behavior->getI18nTable()));
     $tablePhpName = $this->builder->getObjectClassName();
     $objectBuilder = $this->builder->getNewObjectBuilder($this->behavior->getI18nTable());
     $comment = '';
     if ($this->isDateType($column->getType())) {
         $objectBuilder->addTemporalMutatorComment($comment, $column);
     } else {
         $objectBuilder->addMutatorComment($comment, $column);
     }
     $comment = preg_replace('/^\\t/m', '', $comment);
     $comment = str_replace('@return     $this|' . $i18nTablePhpName, '@return     $this|' . $tablePhpName, $comment);
     return $this->renderTemplate('objectTranslatedColumnSetter', ['comment' => $comment, 'column' => $column, 'visibility' => $visibility, 'typeHint' => $typeHint, 'columnPhpName' => $column->getPhpName(), 'localeColumnName' => $this->behavior->getLocaleColumn()->getPhpName()]);
 }
开发者ID:gossi,项目名称:propel-l10n-behavior,代码行数:29,代码来源:L10nBehaviorObjectBuilderModifier.php

示例2: addFilterByColIn

    /**
     * @param \Propel\Generator\Model\Column $col
     *
     * @return string
     */
    protected function addFilterByColIn(Column $col)
    {
        $script = '';
        if ($col->isNumericType() || $col->isTemporalType() || $col->getType() == PropelTypes::ENUM || $col->isTextType()) {
            $colPhpName = $col->getPhpName();
            $variableName = $col->getCamelCaseName();
            $queryClassName = $this->getQueryClassName();
            $script .= <<<SCRIPT

    /**
     * Applies Criteria::IN filtering criteria for the column.
     *
     * @param array \${$variableName}s Filter value.
     *
     * @return \$this|{$queryClassName} The current query, for fluid interface
     */
    public function filterBy{$colPhpName}_In(array \${$variableName}s)
    {
        return \$this->filterBy{$colPhpName}(\${$variableName}s, Criteria::IN);
    }

SCRIPT;
        }
        return $script;
    }
开发者ID:spryker,项目名称:Propel,代码行数:30,代码来源:QueryBuilder.php

示例3: getColumnBindingPHP

 /**
  * Get the PHP snippet for binding a value to a column.
  * Warning: duplicates logic from OracleAdapter::bindValue().
  * Any code modification here must be ported there.
  */
 public function getColumnBindingPHP(Column $column, $identifier, $columnValueAccessor, $tab = "            ")
 {
     if ($column->getPDOType() == PropelTypes::CLOB_EMU) {
         return sprintf("%s\$stmt->bindParam(%s, %s, %s, strlen(%s));\n", $tab, $identifier, $columnValueAccessor, PropelTypes::getPdoTypeString($column->getType()), $columnValueAccessor);
     }
     return parent::getColumnBindingPHP($column, $identifier, $columnValueAccessor, $tab);
 }
开发者ID:smoqs,项目名称:Propel2,代码行数:12,代码来源:OraclePlatform.php

示例4: addRemoveArrayElement

 /**
  * Adds a remove method for an array column.
  * @param string &$script The script will be modified in this method.
  * @param Column $col     The current column.
  */
 protected function addRemoveArrayElement(&$script, Column $col)
 {
     $clo = $col->getLowercasedName();
     $cfc = $col->getPhpName();
     $visibility = $col->getAccessorVisibility();
     $singularPhpName = $col->getPhpSingularName();
     $columnType = $col->getType() === PropelTypes::PHP_ARRAY ? 'array' : 'set';
     $script .= "\n    /**\n     * Removes a value from the [{$clo}] {$columnType} column value.\n     * @param  mixed \$value\n     * " . $col->getDescription();
     if ($col->isLazyLoad()) {
         $script .= "\n     * @param  ConnectionInterface \$con An optional ConnectionInterface connection to use for fetching this lazy-loaded column.";
     }
     $script .= "\n     * @return \$this|" . $this->getObjectClassName(true) . " The current object (for fluent API support)\n     */\n    {$visibility} function remove{$singularPhpName}(\$value";
     if ($col->isLazyLoad()) {
         $script .= ", ConnectionInterface \$con = null";
     }
     // we want to reindex the array, so array_ functions are not the best choice
     $script .= ")\n    {\n        \$targetArray = array();\n        foreach (\$this->get{$cfc}(";
     if ($col->isLazyLoad()) {
         $script .= "\$con";
     }
     $script .= ") as \$element) {\n            if (\$element != \$value) {\n                \$targetArray []= \$element;\n            }\n        }\n        \$this->set{$cfc}(\$targetArray);\n\n        return \$this;\n    } // remove{$singularPhpName}()\n";
 }
开发者ID:SwissalpS,项目名称:Propel2,代码行数:27,代码来源:ObjectBuilder.php

示例5: getColumnDDL

 public function getColumnDDL(Column $col)
 {
     $domain = $col->getDomain();
     $ddl = array($this->quoteIdentifier($col->getName()));
     $sqlType = $domain->getSqlType();
     $table = $col->getTable();
     if ($col->isAutoIncrement() && $table && $table->getIdMethodParameters() == null) {
         $sqlType = $col->getType() === PropelTypes::BIGINT ? 'bigserial' : 'serial';
     }
     if ($this->hasSize($sqlType) && $col->isDefaultSqlType($this)) {
         $ddl[] = $sqlType . $domain->printSize();
     } else {
         $ddl[] = $sqlType;
     }
     if ($default = $this->getColumnDefaultValueDDL($col)) {
         $ddl[] = $default;
     }
     if ($notNull = $this->getNullString($col->isNotNull())) {
         $ddl[] = $notNull;
     }
     if ($autoIncrement = $col->getAutoIncrementString()) {
         $ddl[] = $autoIncrement;
     }
     return implode(' ', $ddl);
 }
开发者ID:RafalFilipek,项目名称:Propel2,代码行数:25,代码来源:PgsqlPlatform.php

示例6: 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

示例7: addLazyLoaderBody

 /**
  * Adds the function body for the lazy loader method.
  *
  * @param string &$script
  * @param Column $column
  */
 protected function addLazyLoaderBody(&$script, Column $column)
 {
     $platform = $this->getPlatform();
     $clo = $column->getLowercasedName();
     // pdo_sqlsrv driver requires the use of PDOStatement::bindColumn() or a hex string will be returned
     if ($column->getType() === PropelTypes::BLOB && $platform instanceof SqlsrvPlatform) {
         $script .= "\n        \$c = \$this->buildPkeyCriteria();\n        \$c->addSelectColumn(" . $this->getColumnConstant($column) . ");\n        try {\n            \$row = array(0 => null);\n            \$dataFetcher = " . $this->getQueryClassName() . "::create(null, \$c)->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find(\$con);\n            if (\$dataFetcher instanceof PDODataFetcher) {\n                \$dataFetcher->bindColumn(1, \$row[0], PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY);\n            }\n            \$row = \$dataFetcher->fetch(PDO::FETCH_BOUND);\n            \$dataFetcher->close();";
     } else {
         $script .= "\n        \$c = \$this->buildPkeyCriteria();\n        \$c->addSelectColumn(" . $this->getColumnConstant($column) . ");\n        try {\n            \$dataFetcher = " . $this->getQueryClassName() . "::create(null, \$c)->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find(\$con);\n            \$row = \$dataFetcher->fetch();\n            \$dataFetcher->close();";
     }
     $script .= "\n\n        \$firstColumn = \$row ? current(\$row) : null;\n";
     if ($column->getType() === PropelTypes::CLOB && $platform instanceof OraclePlatform) {
         // PDO_OCI returns a stream for CLOB objects, while other PDO adapters return a string...
         $script .= "\n            if (\$firstColumn) {\n                \$this->{$clo} = stream_get_contents(\$firstColumn);\n            }";
     } elseif ($column->isLobType() && !$platform->hasStreamBlobImpl()) {
         $script .= "\n            if (\$firstColumn !== null) {\n                \$this->{$clo} = fopen('php://memory', 'r+');\n                fwrite(\$this->{$clo}, \$firstColumn);\n                rewind(\$this->{$clo});\n            } else {\n                \$this->{$clo} = null;\n            }";
     } elseif ($column->isPhpPrimitiveType()) {
         $script .= "\n            \$this->{$clo} = (\$firstColumn !== null) ? (" . $column->getPhpType() . ") \$firstColumn : null;";
     } elseif ($column->isPhpObjectType()) {
         $script .= "\n            \$this->{$clo} = (\$firstColumn !== null) ? new " . $column->getPhpType() . "(\$firstColumn) : null;";
     } else {
         $script .= "\n            \$this->{$clo} = \$firstColumn;";
     }
     $script .= "\n            \$this->" . $clo . "_isLoaded = true;\n        } catch (Exception \$e) {\n            throw new PropelException(\"Error loading value for [{$clo}] column on demand.\", 0, \$e);\n        }";
 }
开发者ID:KyleGoslan,项目名称:Huge-Propel,代码行数:31,代码来源:ObjectBuilder.php

示例8: getColumnDefaultValueDDL

 /**
  * Returns the SQL for the default value of a Column object
  * @return     string
  */
 public function getColumnDefaultValueDDL(Column $col)
 {
     $default = '';
     $defaultValue = $col->getDefaultValue();
     if ($defaultValue !== null) {
         $default .= 'DEFAULT ';
         if ($defaultValue->isExpression()) {
             $default .= $defaultValue->getValue();
         } else {
             if ($col->isTextType()) {
                 $default .= $this->quote($defaultValue->getValue());
             } elseif ($col->getType() == PropelTypes::BOOLEAN || $col->getType() == PropelTypes::BOOLEAN_EMU) {
                 $default .= $this->getBooleanString($defaultValue->getValue());
             } elseif ($col->getType() == PropelTypes::ENUM) {
                 $default .= array_search($defaultValue->getValue(), $col->getValueSet());
             } else {
                 $default .= $defaultValue->getValue();
             }
         }
     }
     return $default;
 }
开发者ID:rouffj,项目名称:Propel2,代码行数:26,代码来源:DefaultPlatform.php

示例9: addTranslatedColumnSetter

 protected function addTranslatedColumnSetter(Column $column)
 {
     $i18nTablePhpName = $this->builder->getNewStubObjectBuilder($this->behavior->getI18nTable())->getClassname();
     $tablePhpName = $this->builder->getStubObjectBuilder()->getClassname();
     $objectBuilder = $this->builder->getNewObjectBuilder($this->behavior->getI18nTable());
     $comment = '';
     $functionStatement = '';
     if ($column->getType() === PropelTypes::DATE || $column->getType() === PropelTypes::TIME || $column->getType() === PropelTypes::TIMESTAMP) {
         $objectBuilder->addTemporalMutatorComment($comment, $column);
         $objectBuilder->addMutatorOpenOpen($functionStatement, $column);
     } else {
         $objectBuilder->addMutatorComment($comment, $column);
         $objectBuilder->addMutatorOpenOpen($functionStatement, $column);
     }
     $comment = preg_replace('/^\\t/m', '', $comment);
     $comment = str_replace('@return     ' . $i18nTablePhpName, '@return     ' . $tablePhpName, $comment);
     $functionStatement = preg_replace('/^\\t/m', '', $functionStatement);
     preg_match_all('/\\$[a-z]+/i', $functionStatement, $params);
     return $this->behavior->renderTemplate('objectTranslatedColumnSetter', array('comment' => $comment, 'functionStatement' => $functionStatement, 'columnPhpName' => $column->getPhpName(), 'params' => implode(', ', $params[0])));
 }
开发者ID:rouffj,项目名称:Propel2,代码行数:20,代码来源:I18nBehaviorObjectBuilderModifier.php

示例10: addLazyLoaderBody

 /**
  * Adds the function body for the lazy loader method
  * @param      string &$script The script will be modified in this method.
  * @param      Column $col The current column.
  * @see        addLazyLoader()
  **/
 protected function addLazyLoaderBody(&$script, Column $col)
 {
     $platform = $this->getPlatform();
     $clo = strtolower($col->getName());
     // pdo_sqlsrv driver requires the use of PDOStatement::bindColumn() or a hex string will be returned
     if ($col->getType() === PropelTypes::BLOB && $platform instanceof SqlsrvPlatform) {
         $script .= "\n        \$c = \$this->buildPkeyCriteria();\n        \$c->addSelectColumn(" . $this->getColumnConstant($col) . ");\n        try {\n            \$row = array(0 => null);\n            \$stmt = " . $this->getPeerClassname() . "::doSelectStmt(\$c, \$con);\n            \$stmt->bindColumn(1, \$row[0], PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY);\n            \$stmt->fetch(PDO::FETCH_BOUND);\n            \$stmt->closeCursor();";
     } else {
         $script .= "\n        \$c = \$this->buildPkeyCriteria();\n        \$c->addSelectColumn(" . $this->getColumnConstant($col) . ");\n        try {\n            \$stmt = " . $this->getPeerClassname() . "::doSelectStmt(\$c, \$con);\n            \$row = \$stmt->fetch(PDO::FETCH_NUM);\n            \$stmt->closeCursor();";
     }
     if ($col->getType() === PropelTypes::CLOB && $platform instanceof OraclePlatform) {
         // PDO_OCI returns a stream for CLOB objects, while other PDO adapters return a string...
         $script .= "\n            \$this->{$clo} = stream_get_contents(\$row[0]);";
     } elseif ($col->isLobType() && !$platform->hasStreamBlobImpl()) {
         $script .= "\n            if (\$row[0] !== null) {\n                \$this->{$clo} = fopen('php://memory', 'r+');\n                fwrite(\$this->{$clo}, \$row[0]);\n                rewind(\$this->{$clo});\n            } else {\n                \$this->{$clo} = null;\n            }";
     } elseif ($col->isPhpPrimitiveType()) {
         $script .= "\n            \$this->{$clo} = (\$row[0] !== null) ? (" . $col->getPhpType() . ") \$row[0] : null;";
     } elseif ($col->isPhpObjectType()) {
         $script .= "\n            \$this->{$clo} = (\$row[0] !== null) ? new " . $col->getPhpType() . "(\$row[0]) : null;";
     } else {
         $script .= "\n            \$this->{$clo} = \$row[0];";
     }
     $script .= "\n            \$this->" . $clo . "_isLoaded = true;\n        } catch (Exception \$e) {\n            throw new PropelException(\"Error loading value for [{$clo}] column on demand.\", 0, \$e);\n        }";
 }
开发者ID:rouffj,项目名称:Propel2,代码行数:30,代码来源:ObjectBuilder.php

示例11: appendColumnNode

 /**
  * Appends the generated <column> XML node to its parent node.
  *
  * @param Column   $column     The Column model instance
  * @param \DOMNode $parentNode The parent DOMNode object
  */
 private function appendColumnNode(Column $column, \DOMNode $parentNode)
 {
     $columnNode = $parentNode->appendChild($this->document->createElement('column'));
     $columnNode->setAttribute('name', $column->getName());
     if ($phpName = $column->getPhpName()) {
         $columnNode->setAttribute('phpName', $phpName);
     }
     $columnNode->setAttribute('type', $column->getType());
     $domain = $column->getDomain();
     if ($size = $domain->getSize()) {
         $columnNode->setAttribute('size', $size);
     }
     if (null !== ($scale = $domain->getScale())) {
         $columnNode->setAttribute('scale', $scale);
     }
     $platform = $column->getPlatform();
     if ($platform && !$column->isDefaultSqlType($platform)) {
         $columnNode->setAttribute('sqlType', $domain->getSqlType());
     }
     if ($description = $column->getDescription()) {
         $columnNode->setAttribute('description', $description);
     }
     if ($column->isPrimaryKey()) {
         $columnNode->setAttribute('primaryKey', 'true');
     }
     if ($column->isAutoIncrement()) {
         $columnNode->setAttribute('autoIncrement', 'true');
     }
     if ($column->isNotNull()) {
         $columnNode->setAttribute('required', 'true');
     }
     $defaultValue = $domain->getDefaultValue();
     if ($defaultValue) {
         $type = $defaultValue->isExpression() ? 'defaultExpr' : 'defaultValue';
         $columnNode->setAttribute($type, $defaultValue->getValue());
     }
     if ($column->isInheritance()) {
         $columnNode->setAttribute('inheritance', $column->getInheritanceType());
         foreach ($column->getInheritanceList() as $inheritance) {
             $this->appendInheritanceNode($inheritance, $columnNode);
         }
     }
     if ($column->isNodeKey()) {
         $columnNode->setAttribute('nodeKey', 'true');
         if ($nodeKeySeparator = $column->getNodeKeySep()) {
             $columnNode->setAttribute('nodeKeySep', $nodeKeySeparator);
         }
     }
     foreach ($column->getVendorInformation() as $vendorInformation) {
         $this->appendVendorInformationNode($vendorInformation, $columnNode);
     }
 }
开发者ID:SwissalpS,项目名称:Propel2,代码行数:58,代码来源:XmlDumper.php

示例12: getColumnDefaultValueDDL

 /**
  * Returns the SQL for the default value of a Column object
  * @return string
  */
 public function getColumnDefaultValueDDL(Column $col)
 {
     $default = '';
     $defaultValue = $col->getDefaultValue();
     if (null !== $defaultValue) {
         $default .= 'DEFAULT ';
         if ($defaultValue->isExpression()) {
             $default .= $defaultValue->getValue();
         } else {
             if ($col->isTextType()) {
                 $default .= $this->quote($defaultValue->getValue());
             } elseif (in_array($col->getType(), [PropelTypes::BOOLEAN, PropelTypes::BOOLEAN_EMU])) {
                 $default .= $this->getBooleanString($defaultValue->getValue());
             } elseif ($col->getType() == PropelTypes::ENUM) {
                 $default .= array_search($defaultValue->getValue(), $col->getValueSet());
             } elseif ($col->isPhpArrayType()) {
                 $value = $this->getPhpArrayString($defaultValue->getValue());
                 if (null === $value) {
                     $default = '';
                 } else {
                     $default .= $value;
                 }
             } else {
                 $default .= $defaultValue->getValue();
             }
         }
     }
     return $default;
 }
开发者ID:eat24,项目名称:propel,代码行数:33,代码来源:DefaultPlatform.php


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