本文整理汇总了PHP中Propel\Generator\Model\Column::getTable方法的典型用法代码示例。如果您正苦于以下问题:PHP Column::getTable方法的具体用法?PHP Column::getTable怎么用?PHP Column::getTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Generator\Model\Column
的用法示例。
在下文中一共展示了Column::getTable方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()]);
}
示例2: getRemoveColumnDDL
/**
* Builds the DDL SQL to remove a column
*
* @return string
*/
public function getRemoveColumnDDL(Column $column)
{
$pattern = "\nALTER TABLE %s DROP %s;\n";
return sprintf($pattern, $this->quoteIdentifier($column->getTable()->getName()), $this->quoteIdentifier($column->getName()));
}
示例3: 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);
}
示例4: 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);
}
示例5: testSetTable
public function testSetTable()
{
$column = new Column();
$column->setTable($this->getTableMock('books'));
$this->assertInstanceOf('Propel\\Generator\\Model\\Table', $column->getTable());
$this->assertSame('books', $column->getTableName());
}
示例6: 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;
}
示例7: 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));
}
示例8: 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()]);
}
示例9: isColumnForeignKeyOrDuplicated
/**
* @param Column $column
*
* @return bool
*
* @throws PropelException
*/
protected function isColumnForeignKeyOrDuplicated(Column $column)
{
$delegateTable = $column->getTable();
$table = $this->getTable();
$fks = [];
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)) {
return true;
} else {
if ($table->hasColumn($column->getName())) {
throw new PropelException('Column with name «' . $column->getName() . '» (delegated from table «' . $delegateTable->getName() . '») already exists in table «' . $table->getName() . '». Probably database design mistake');
}
return false;
}
}