本文整理汇总了PHP中Propel\Generator\Model\Column::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Column::getName方法的具体用法?PHP Column::getName怎么用?PHP Column::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Generator\Model\Column
的用法示例。
在下文中一共展示了Column::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addClosureColumn
protected function addClosureColumn($name, Table $ct_table, Column $column)
{
$table = $this->getTable();
$id_fieldname = $column->getName();
$domain = $column->getDomain();
if (!$ct_table->hasColumn($name)) {
$column = new Column($name);
$column->setDomain($domain);
$column->setPrimaryKey(true);
$ct_table->addColumn($column);
} else {
$column = $ct_table->getColumn($name);
}
$ct_tablename_normalized = str_replace('_', '', $ct_table->getName());
$fk_name = $ct_tablename_normalized . '_' . $name . '_fk';
if (!$ct_table->getColumnForeignKeys($name)) {
$column_fk = new ForeignKey($fk_name);
$column_fk->addReference($name, $table->getColumn($id_fieldname)->getName());
$column_fk->setForeignTableCommonName($table->getName());
$column_fk->setOnUpdate('cascade');
$column_fk->setOnDelete('restrict');
$ct_table->addForeignKey($column_fk);
}
$column_idx_name = $fk_name . '_idx';
if (!$ct_table->hasIndex($column_idx_name)) {
$column_idx = new Index($column_idx_name);
$column_idx->addColumn(['name' => $column->getName()]);
$ct_table->addIndex($column_idx);
}
}
示例2: getAddColumnDDL
/**
* Builds the DDL SQL to add a column
*
* @param Column $column
*
* @return string
*/
public function getAddColumnDDL(Column $column)
{
$pattern = "\nALTER TABLE %s ADD %s %s;\n";
$tableColumns = $column->getTable()->getColumns();
// Default to add first if no column is found before the current one
$insertPositionDDL = "FIRST";
foreach ($tableColumns as $i => $tableColumn) {
// We found the column, use the one before it if it's not the first
if ($tableColumn->getName() == $column->getName()) {
// We have a column that is not the first one
if ($i > 0) {
$insertPositionDDL = "AFTER " . $this->quoteIdentifier($tableColumns[$i - 1]->getName());
}
break;
}
}
return sprintf($pattern, $this->quoteIdentifier($column->getTable()->getName()), $this->getColumnDDL($column), $insertPositionDDL);
}
示例3: addColumn
/**
* Adds a new column to the table.
*
* @param Column|array $col
* @throws EngineException
* @return Column
*/
public function addColumn($col)
{
if ($col instanceof Column) {
if (isset($this->columnsByName[$col->getName()])) {
throw new EngineException(sprintf('Column "%s" declared twice in table "%s"', $col->getName(), $this->getName()));
}
$col->setTable($this);
if ($col->isInheritance()) {
$this->inheritanceColumn = $col;
}
$this->columns[] = $col;
$this->columnsByName[$col->getName()] = $col;
$this->columnsByLowercaseName[strtolower($col->getName())] = $col;
$this->columnsByPhpName[$col->getPhpName()] = $col;
$col->setPosition(count($this->columns));
if ($col->requiresTransactionInPostgres()) {
$this->needsTransactionInPostgres = true;
}
return $col;
}
$column = new Column();
$column->setTable($this);
$column->loadMapping($col);
return $this->addColumn($column);
// call self w/ different param
}
示例4: addFilterBySetCol
/**
* Adds the singular filterByCol method for an Array column.
*
* @param string &$script The script will be modified in this method.
* @param Column $col
*/
protected function addFilterBySetCol(&$script, Column $col)
{
$colPhpName = $col->getPhpName();
$singularPhpName = $col->getPhpSingularName();
$colName = $col->getName();
$variableName = $col->getCamelCaseName();
$script .= "\n /**\n * Filter the query on the {$colName} column\n * @param mixed \${$variableName} The value to use as filter\n * @param string \$comparison Operator to use for the column comparison, defaults to Criteria::CONTAINS_ALL\n *\n * @return \$this|" . $this->getQueryClassName() . " The current query, for fluid interface\n */\n public function filterBy{$singularPhpName}(\${$variableName} = null, \$comparison = null)\n {\n return \$this->filterBy{$colPhpName}(\${$variableName}, \$comparison);\n }\n";
}
示例5: addDefaultMutator
/**
* Adds setter method for "normal" columns.
* @param string &$script The script will be modified in this method.
* @param Column $col The current column.
* @see parent::addColumnMutators()
*/
protected function addDefaultMutator(&$script, Column $col)
{
$clo = strtolower($col->getName());
$this->addMutatorOpen($script, $col);
// Perform type-casting to ensure that we can use type-sensitive
// checking in mutators.
if ($col->isPhpPrimitiveType()) {
$script .= "\n if (\$v !== null) {\n \$v = (" . $col->getPhpType() . ") \$v;\n }\n";
}
$script .= "\n if (\$this->{$clo} !== \$v) {\n \$this->{$clo} = \$v;\n \$this->modifiedColumns[] = " . $this->getColumnConstant($col) . ";\n }\n";
$this->addMutatorClose($script, $col);
}
示例6: addFindOne
protected function addFindOne(Column $column)
{
return $this->renderTemplate('queryFindOne', ['objectClassName' => $this->builder->getClassNameFromBuilder($this->builder->getStubObjectBuilder($column->getTable())), 'columnPhpName' => $column->getPhpName(), 'columnName' => $column->getName(), 'localeColumnName' => $this->behavior->getLocaleColumn()->getPhpName()]);
}
示例7: getColumnConstant
/**
* Get the column constant name (e.g. TableMapName::COLUMN_NAME).
*
* @param Column $col The column we need a name for.
* @param string $classname The TableMap classname to use.
*
* @return string If $classname is provided, then will return $classname::COLUMN_NAME; if not, then the TableMapName is looked up for current table to yield $currTableTableMap::COLUMN_NAME.
*/
public function getColumnConstant($col, $classname = null)
{
if (null === $col) {
throw new InvalidArgumentException('No columns were specified.');
}
if (null === $classname) {
return $this->getBuildProperty('classPrefix') . $col->getConstantName();
}
// was it overridden in schema.xml ?
if ($col->getTableMapName()) {
$const = strtoupper($col->getTableMapName());
} else {
$const = strtoupper($col->getName());
}
return $classname . '::' . $const;
}
示例8: addMutatorCloseBody
/**
* Adds the body of the close part of a mutator.
*
* @param string &$script
* @param Column $column
*/
protected function addMutatorCloseBody(&$script, Column $column)
{
$table = $this->getTable();
if ($column->isForeignKey()) {
foreach ($column->getForeignKeys() as $fk) {
$tblFK = $table->getDatabase()->getTable($fk->getForeignTableName());
$colFK = $tblFK->getColumn($fk->getMappedForeignColumn($column->getName()));
if (!$colFK) {
continue;
}
$varName = $this->getFKVarName($fk);
$script .= "\n if (\$this->{$varName} !== null && \$this->" . $varName . "->get" . $colFK->getPhpName() . "() !== \$v) {\n \$this->{$varName} = null;\n }\n";
}
// foreach fk
}
/* if col is foreign key */
foreach ($column->getReferrers() as $refFK) {
$tblFK = $this->getDatabase()->getTable($refFK->getForeignTableName());
if ($tblFK->getName() != $table->getName()) {
foreach ($column->getForeignKeys() as $fk) {
$tblFK = $table->getDatabase()->getTable($fk->getForeignTableName());
$colFK = $tblFK->getColumn($fk->getMappedForeignColumn($column->getName()));
if ($refFK->isLocalPrimaryKey()) {
$varName = $this->getPKRefFKVarName($refFK);
$script .= "\n // update associated " . $tblFK->getPhpName() . "\n if (\$this->{$varName} !== null) {\n \$this->{$varName}->set" . $colFK->getPhpName() . "(\$v);\n }\n";
} else {
$collName = $this->getRefFKCollVarName($refFK);
$script .= "\n\n // update associated " . $tblFK->getPhpName() . "\n if (\$this->{$collName} !== null) {\n foreach (\$this->{$collName} as \$referrerObject) {\n \$referrerObject->set" . $colFK->getPhpName() . "(\$v);\n }\n }\n";
}
// if (isLocalPrimaryKey
}
// foreach col->getPrimaryKeys()
}
// if tablFk != table
}
// foreach
}
示例9: addColumnToLog
/**
* Adds the actual column which want to track.
*
* @param Table $logTable
* @param Column $column
*/
protected function addColumnToLog(Table $logTable, Column $column)
{
if ($logTable->hasColumn($column->getName())) {
return;
}
$columnInLogTable = clone $column;
if ($columnInLogTable->hasReferrers()) {
$columnInLogTable->clearReferrers();
}
$columnInLogTable->setAutoIncrement(false);
$columnInLogTable->setPrimaryKey(false);
$logTable->addColumn($columnInLogTable);
}
示例10: isColumnForeignKeyOrDuplicated
/**
* @param Column $column
*
* @return bool
*
* @throws PropelException
*/
protected function isColumnForeignKeyOrDuplicated(Column $column)
{
$delegateTable = $column->getTable();
$table = $this->getTable();
$fks = [];
if (!isset($this->double_defined)) {
$this->double_defined = [];
foreach ($this->delegates + [$table->getName() => 1] as $key => $value) {
$delegateTable = $this->getDelegateTable($key);
foreach ($delegateTable->getColumns() as $columnDelegated) {
if (isset($this->double_defined[$columnDelegated->getName()])) {
$this->double_defined[$columnDelegated->getName()]++;
} else {
$this->double_defined[$columnDelegated->getName()] = 1;
}
}
}
}
if (1 < $this->double_defined[$column->getName()]) {
return true;
}
foreach ($delegateTable->getForeignKeysReferencingTable($table->getName()) as $fk) {
/** @var \Propel\Generator\Model\ForeignKey $fk */
$fks[] = $fk->getForeignColumnName();
}
foreach ($table->getForeignKeysReferencingTable($delegateTable->getName()) as $fk) {
$fks[] = $fk->getForeignColumnName();
}
if (in_array($column->getName(), $fks) || $table->hasColumn($column->getName())) {
return true;
}
return false;
}
示例11: getColumnName
/**
* Gets the name of the column that this Validator applies to.
* @return string
*/
public function getColumnName()
{
return $this->column->getName();
}
示例12: getColumnName
/**
* COMPATIBILITY: Get the column constant name (e.g. PeerName::COLUMN_NAME).
*
* This method exists simply because it belonged to the 'PeerBuilder' that this
* class is replacing (because of name conflict more than actual functionality overlap).
* When the new builder model is finished this method will be removed.
*
* @param Column $col The column we need a name for.
* @param string $phpName The PHP Name of the peer class. The 'Peer' is appended automatically.
*
* @return string If $phpName is provided, then will return {$phpName}Peer::COLUMN_NAME; if not, just COLUMN_NAME.
* @deprecated
*/
public static function getColumnName(Column $col, $phpName = null)
{
// was it overridden in schema.xml ?
if ($col->getPeerName()) {
$const = strtoupper($col->getPeerName());
} else {
$const = strtoupper($col->getName());
}
if ($phpName !== null) {
return $phpName . 'Peer::' . $const;
} else {
return $const;
}
}
示例13: getChangeColumnDDL
/**
* Builds the DDL SQL to change a column
* @return string
*/
public function getChangeColumnDDL(Column $fromColumn, Column $toColumn)
{
$pattern = "\nALTER TABLE %s CHANGE %s %s;\n";
return sprintf($pattern, $this->quoteIdentifier($fromColumn->getTable()->getName()), $this->quoteIdentifier($fromColumn->getName()), $this->getColumnDDL($toColumn));
}
示例14: addFilterByCol
/**
* Adds the filterByCol method for this object.
*
* @param string &$script The script will be modified in this method.
* @param \Propel\Generator\Model\Column $col
*
* @return void
*/
protected function addFilterByCol(&$script, Column $col)
{
$allowedArrayFilters = $this->getAllowedArrayFilters();
$implodedArrayComparisons = implode(', ', $allowedArrayFilters);
$this->declareClass('Spryker\\Zed\\Propel\\Business\\Exception\\AmbiguousComparisonException');
$this->declareClass('Spryker\\Zed\\Propel\\Business\\Runtime\\ActiveQuery\\Criteria', 'Spryker');
$colPhpName = $col->getPhpName();
$colName = $col->getName();
$variableName = $col->getCamelCaseName();
$qualifiedName = $this->getColumnConstant($col);
$script .= $this->addFilterByColBetween($col);
$script .= $this->addFilterByColIn($col);
$script .= $this->addFilterByColLike($col);
$script .= "\n /**\n * Filter the query on the {$colName} column\n *";
if ($col->isNumericType()) {
$script .= "\n * Example usage:\n * <code>\n * \$query->filterBy{$colPhpName}(1234); // WHERE {$colName} = 1234\n * \$query->filterBy{$colPhpName}(array(12, 34), Criteria::IN); // WHERE {$colName} IN (12, 34)\n * \$query->filterBy{$colPhpName}(array('min' => 12), SprykerCriteria::BETWEEN); // WHERE {$colName} > 12\n * </code>";
if ($col->isForeignKey()) {
foreach ($col->getForeignKeys() as $fk) {
$script .= "\n *\n * @see filterBy" . $this->getFKPhpNameAffix($fk) . "()";
}
}
$script .= "\n *\n * @param mixed \${$variableName} The value to use as filter.\n * Use scalar values for equality.\n * Use array values for in_array() equivalent. Add Criteria::IN explicitly.\n * Use associative array('min' => \$minValue, 'max' => \$maxValue) for intervals. Add SprykerCriteria::BETWEEN explicitly.";
} elseif ($col->isTemporalType()) {
$script .= "\n * Example usage:\n * <code>\n * \$query->filterBy{$colPhpName}('2011-03-14'); // WHERE {$colName} = '2011-03-14'\n * \$query->filterBy{$colPhpName}('now'); // WHERE {$colName} = '2011-03-14'\n * \$query->filterBy{$colPhpName}(array('max' => 'yesterday'), SprykerCriteria::BETWEEN); // WHERE {$colName} > '2011-03-13'\n * </code>\n *\n * @param mixed \${$variableName} The value to use as filter.\n * Values can be integers (unix timestamps), DateTime objects, or strings.\n * Empty strings are treated as NULL.\n * Use scalar values for equality.\n * Use array values for in_array() equivalent. Add Criteria::IN explicitly.\n * Use associative array('min' => \$minValue, 'max' => \$maxValue) for intervals. Add SprykerCriteria::BETWEEN explicitly.";
} elseif ($col->getType() == PropelTypes::PHP_ARRAY) {
$script .= "\n * @param array \${$variableName} The values to use as filter. Use Criteria::LIKE to enable like matching of array values.";
} elseif ($col->isTextType()) {
$script .= "\n * Example usage:\n * <code>\n * \$query->filterBy{$colPhpName}('fooValue'); // WHERE {$colName} = 'fooValue'\n * \$query->filterBy{$colPhpName}('%fooValue%', Criteria::LIKE); // WHERE {$colName} LIKE '%fooValue%'\n * </code>\n *\n * @param string \${$variableName} The value to use as filter.\n * Accepts wildcards (* and % trigger a LIKE). Add Criteria::LIKE explicitly.";
} elseif ($col->isBooleanType()) {
$script .= "\n * Example usage:\n * <code>\n * \$query->filterBy{$colPhpName}(true); // WHERE {$colName} = true\n * \$query->filterBy{$colPhpName}('yes'); // WHERE {$colName} = true\n * </code>\n *\n * @param boolean|string \${$variableName} The value to use as filter.\n * Non-boolean arguments are converted using the following rules:\n * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true\n * * 0, '0', 'false', 'off', and 'no' are converted to boolean false\n * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').";
} else {
$script .= "\n * @param mixed \${$variableName} The value to use as filter";
}
$script .= "\n * @param string \$comparison Operator to use for the column comparison, defaults to Criteria::EQUAL\n *\n * @return \$this|" . $this->getQueryClassName() . " The current query, for fluid interface\n *\n * @throws \\Spryker\\Zed\\Propel\\Business\\Exception\\AmbiguousComparisonException\n */\n public function filterBy{$colPhpName}(\${$variableName} = null, \$comparison = Criteria::EQUAL)\n {";
if ($col->isNumericType() || $col->isTemporalType()) {
$script .= "\n\n if (is_array(\${$variableName})) {\n \$useMinMax = false;\n if (isset(\${$variableName}['min'])) {\n if (\$comparison != SprykerCriteria::BETWEEN && \$comparison != Criteria::GREATER_EQUAL) {\n throw new AmbiguousComparisonException('\\'min\\' requires explicit Criteria::GREATER_EQUAL or SprykerCriteria::BETWEEN when \\'max\\' is also needed as comparison criteria.');\n }\n \$this->addUsingAlias({$qualifiedName}, \${$variableName}['min'], Criteria::GREATER_EQUAL);\n \$useMinMax = true;\n }\n if (isset(\${$variableName}['max'])) {\n if (\$comparison != SprykerCriteria::BETWEEN && \$comparison != Criteria::LESS_EQUAL) {\n throw new AmbiguousComparisonException('\\'max\\' requires explicit Criteria::LESS_EQUAL or SprykerCriteria::BETWEEN when \\'min\\' is also needed as comparison criteria.');\n }\n \$this->addUsingAlias({$qualifiedName}, \${$variableName}['max'], Criteria::LESS_EQUAL);\n \$useMinMax = true;\n }\n if (\$useMinMax) {\n return \$this;\n }\n\n if (!in_array(\$comparison, [{$implodedArrayComparisons}])) {\n throw new AmbiguousComparisonException('\${$variableName} of type array requires one of [{$implodedArrayComparisons}] as comparison criteria.');\n }\n }";
} elseif ($col->getType() == PropelTypes::OBJECT) {
$script .= "\n if (is_object(\${$variableName})) {\n \${$variableName} = serialize(\${$variableName});\n }";
} elseif ($col->getType() == PropelTypes::PHP_ARRAY) {
$script .= "\n \$key = \$this->getAliasedColName({$qualifiedName});\n if (null === \$comparison || \$comparison == Criteria::CONTAINS_ALL) {\n foreach (\${$variableName} as \$value) {\n \$value = '%| ' . \$value . ' |%';\n if (\$this->containsKey(\$key)) {\n \$this->addAnd(\$key, \$value, Criteria::LIKE);\n } else {\n \$this->add(\$key, \$value, Criteria::LIKE);\n }\n }\n\n return \$this;\n } elseif (\$comparison == Criteria::CONTAINS_SOME) {\n foreach (\${$variableName} as \$value) {\n \$value = '%| ' . \$value . ' |%';\n if (\$this->containsKey(\$key)) {\n \$this->addOr(\$key, \$value, Criteria::LIKE);\n } else {\n \$this->add(\$key, \$value, Criteria::LIKE);\n }\n }\n\n return \$this;\n } elseif (\$comparison == Criteria::CONTAINS_NONE) {\n foreach (\${$variableName} as \$value) {\n \$value = '%| ' . \$value . ' |%';\n if (\$this->containsKey(\$key)) {\n \$this->addAnd(\$key, \$value, Criteria::NOT_LIKE);\n } else {\n \$this->add(\$key, \$value, Criteria::NOT_LIKE);\n }\n }\n \$this->addOr(\$key, null, Criteria::ISNULL);\n\n return \$this;\n }";
} elseif ($col->getType() == PropelTypes::ENUM) {
$script .= "\n \$valueSet = " . $this->getTableMapClassName() . "::getValueSet(" . $this->getColumnConstant($col) . ");\n if (is_scalar(\${$variableName})) {\n if (!in_array(\${$variableName}, \$valueSet)) {\n throw new PropelException(sprintf('Value \"%s\" is not accepted in this enumerated column', \${$variableName}));\n }\n \${$variableName} = array_search(\${$variableName}, \$valueSet);\n } elseif (is_array(\${$variableName})) {\n if (!in_array(\$comparison, [{$implodedArrayComparisons}])) {\n throw new AmbiguousComparisonException('array requires one of [{$implodedArrayComparisons}] as comparison criteria.');\n }\n \$convertedValues = array();\n foreach (\${$variableName} as \$value) {\n if (!in_array(\$value, \$valueSet)) {\n throw new PropelException(sprintf('Value \"%s\" is not accepted in this enumerated column', \$value));\n }\n \$convertedValues []= array_search(\$value, \$valueSet);\n }\n \${$variableName} = \$convertedValues;\n }";
} elseif ($col->isTextType()) {
$script .= "\n if (\$comparison == Criteria::LIKE) {\n \${$variableName} = str_replace('*', '%', \${$variableName});\n }\n\n if (is_array(\${$variableName}) && !in_array(\$comparison, [{$implodedArrayComparisons}])) {\n throw new AmbiguousComparisonException('\${$variableName} of type array requires one of [{$implodedArrayComparisons}] as comparison criteria.');\n }";
} elseif ($col->isBooleanType()) {
$script .= "\n if (is_string(\${$variableName})) {\n \${$variableName} = in_array(strtolower(\${$variableName}), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;\n }";
}
$script .= "\n\n return \$this->addUsingAlias({$qualifiedName}, \${$variableName}, \$comparison);\n }\n";
}
示例15: getRenameColumnDDL
/**
* Builds the DDL SQL to rename a column
*
* @return string
*/
public function getRenameColumnDDL(Column $fromColumn, Column $toColumn)
{
$pattern = "\nALTER TABLE %s RENAME COLUMN %s TO %s;\n";
return sprintf($pattern, $this->quoteIdentifier($fromColumn->getTable()->getName()), $this->quoteIdentifier($fromColumn->getName()), $this->quoteIdentifier($toColumn->getName()));
}