本文整理汇总了PHP中Doctrine\DBAL\Schema\Column::getAutoincrement方法的典型用法代码示例。如果您正苦于以下问题:PHP Column::getAutoincrement方法的具体用法?PHP Column::getAutoincrement怎么用?PHP Column::getAutoincrement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Schema\Column
的用法示例。
在下文中一共展示了Column::getAutoincrement方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(TableInformation $parent, \Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column)
{
$this->table = $parent;
foreach ($table->getForeignKeys() as $foreign) {
if (in_array($column->getName(), $foreign->getColumns())) {
$foreign_columns = $foreign->getForeignColumns();
$this->foreignTable = $foreign->getForeignTableName();
$this->foreignColumn = reset($foreign_columns);
$this->isForeign = true;
}
}
if ($primary_key = $table->getPrimaryKey()) {
$this->isPrimary = in_array($column->getName(), $primary_key->getColumns());
}
$this->name = $column->getName();
$this->type = $column->getType()->getName();
$this->length = $column->getLength();
$this->precision = $column->getPrecision();
$this->default = $column->getDefault();
$this->isNotNull = $column->getNotnull();
$this->isUnsigned = $column->getUnsigned();
$this->isFixed = $column->getFixed();
$this->isAutoIncrement = $column->getAutoincrement();
$this->comment = $column->getComment();
if ($this->type === \Doctrine\DBAL\Types\Type::BLOB) {
$this->length = min($this->bytesFromIni('post_max_size'), $this->bytesFromIni('upload_max_filesize'));
}
}
示例2: diffColumn
public function diffColumn(Column $column1, Column $column2)
{
$changedProperties = array();
if ($column1->getType() != $column2->getType()) {
//espo: fix problem with executing query for custom types
$column1DbTypeName = method_exists($column1->getType(), 'getDbTypeName') ? $column1->getType()->getDbTypeName() : $column1->getType()->getName();
$column2DbTypeName = method_exists($column2->getType(), 'getDbTypeName') ? $column2->getType()->getDbTypeName() : $column2->getType()->getName();
if (strtolower($column1DbTypeName) != strtolower($column2DbTypeName)) {
$changedProperties[] = 'type';
}
//END: espo
}
if ($column1->getNotnull() != $column2->getNotnull()) {
$changedProperties[] = 'notnull';
}
if ($column1->getDefault() != $column2->getDefault()) {
$changedProperties[] = 'default';
}
if ($column1->getUnsigned() != $column2->getUnsigned()) {
$changedProperties[] = 'unsigned';
}
if ($column1->getType() instanceof \Doctrine\DBAL\Types\StringType) {
// check if value of length is set at all, default value assumed otherwise.
$length1 = $column1->getLength() ?: 255;
$length2 = $column2->getLength() ?: 255;
if ($length1 != $length2) {
$changedProperties[] = 'length';
}
if ($column1->getFixed() != $column2->getFixed()) {
$changedProperties[] = 'fixed';
}
}
if ($column1->getType() instanceof \Doctrine\DBAL\Types\DecimalType) {
if (($column1->getPrecision() ?: 10) != ($column2->getPrecision() ?: 10)) {
$changedProperties[] = 'precision';
}
if ($column1->getScale() != $column2->getScale()) {
$changedProperties[] = 'scale';
}
}
if ($column1->getAutoincrement() != $column2->getAutoincrement()) {
$changedProperties[] = 'autoincrement';
}
// only allow to delete comment if its set to '' not to null.
if ($column1->getComment() !== null && $column1->getComment() != $column2->getComment()) {
$changedProperties[] = 'comment';
}
$options1 = $column1->getCustomSchemaOptions();
$options2 = $column2->getCustomSchemaOptions();
$commonKeys = array_keys(array_intersect_key($options1, $options2));
foreach ($commonKeys as $key) {
if ($options1[$key] !== $options2[$key]) {
$changedProperties[] = $key;
}
}
$diffKeys = array_keys(array_diff_key($options1, $options2) + array_diff_key($options2, $options1));
$changedProperties = array_merge($changedProperties, $diffKeys);
return $changedProperties;
}
示例3: getType
protected function getType(Column $column)
{
$type = 0;
if ($column->getLength() > 0) {
$type += $column->getLength();
}
$type = $type | SerializeTrait::getTypeByDoctrineType($column->getType());
if (!$column->getNotnull()) {
$type = $type | TableInterface::IS_NULL;
}
if ($column->getAutoincrement()) {
$type = $type | TableInterface::AUTO_INCREMENT;
}
return $type;
}
示例4: buildColumn
/**
* @param Column $column
* @param Collection $foreignKeyColumns
* @param Collection $foreignTables
* @param Collection $indexes
* @return ColumnInterface
*/
protected function buildColumn(Column $column, Collection $foreignKeyColumns, Collection $foreignTables, Collection $indexes)
{
$uniqued = $indexes->filter(function (Index $index) use($column) {
return $index->getColumns()[0] == $column->getName() && $index->isUnique();
})->count() > 0;
if ($column->getAutoincrement()) {
return new ColumnAutoincrement($column, null, null, $uniqued);
} else {
if ($foreignKeyColumns->has($column->getName())) {
$table = $foreignKeyColumns->get($column->getName());
return new ColumnSelect($column, $table, $foreignTables->get($table), $uniqued);
} else {
if ($column->getType()->getName() == Type::INTEGER) {
return new ColumnNumericText($column, null, null, $uniqued);
} else {
return new ColumnText($column, null, null, $uniqued);
}
}
}
}
示例5: generateIntFieldInput
/**
* @param string $name
* @param string $type
* @param \Doctrine\DBAL\Schema\Column $column
*
* @return string
*/
private function generateIntFieldInput($name, $type, $column)
{
$fieldInput = "{$name}:{$type}";
if ($column->getAutoincrement()) {
$fieldInput .= ',true';
}
if ($column->getUnsigned()) {
$fieldInput .= ',true';
}
return $fieldInput;
}
示例6: processInt
/**
* Process integer type of the table field.
*
* @param Column $column
* @param bool $isUnique
* @return string
*/
protected function processInt(Column $column, $isUnique)
{
return $this->grammar->integer($column->getName(), $column->getDefault(), !$column->getNotnull(), $column->getUnsigned(), $isUnique, $column->getAutoincrement());
}
示例7: saveColumn
/**
* @param Column $column
* @param \SimpleXMLElement $xml
*/
private static function saveColumn($column, $xml)
{
$xml->addChild('name', $column->getName());
switch ($column->getType()) {
case 'SmallInt':
case 'Integer':
case 'BigInt':
$xml->addChild('type', 'integer');
$default = $column->getDefault();
if (is_null($default) && $column->getAutoincrement()) {
$default = '0';
}
$xml->addChild('default', $default);
$xml->addChild('notnull', self::toBool($column->getNotnull()));
if ($column->getAutoincrement()) {
$xml->addChild('autoincrement', '1');
}
if ($column->getUnsigned()) {
$xml->addChild('unsigned', 'true');
}
$length = '4';
if ($column->getType() == 'SmallInt') {
$length = '2';
} elseif ($column->getType() == 'BigInt') {
$length = '8';
}
$xml->addChild('length', $length);
break;
case 'String':
$xml->addChild('type', 'text');
$default = trim($column->getDefault());
if ($default === '') {
$default = false;
}
$xml->addChild('default', $default);
$xml->addChild('notnull', self::toBool($column->getNotnull()));
$xml->addChild('length', $column->getLength());
break;
case 'Text':
$xml->addChild('type', 'clob');
$xml->addChild('notnull', self::toBool($column->getNotnull()));
break;
case 'Decimal':
$xml->addChild('type', 'decimal');
$xml->addChild('default', $column->getDefault());
$xml->addChild('notnull', self::toBool($column->getNotnull()));
$xml->addChild('length', '15');
break;
case 'Boolean':
$xml->addChild('type', 'integer');
$xml->addChild('default', $column->getDefault());
$xml->addChild('notnull', self::toBool($column->getNotnull()));
$xml->addChild('length', '1');
break;
case 'DateTime':
$xml->addChild('type', 'timestamp');
$xml->addChild('default', $column->getDefault());
$xml->addChild('notnull', self::toBool($column->getNotnull()));
break;
}
}
示例8: doctrineColumnToProcessingType
/**
* @param Column $column
* @return string
* @throws \RuntimeException
*/
private function doctrineColumnToProcessingType(Column $column)
{
if (!isset($this->doctrineProcessingTypeMap[$column->getType()->getName()])) {
throw new \RuntimeException(sprintf("No processing type mapping for doctrine type %s", $column->getType()->getName()));
}
$processingType = $this->doctrineProcessingTypeMap[$column->getType()->getName()];
if (!$column->getNotnull() || $column->getAutoincrement()) {
$processingType .= "OrNull";
if (!class_exists($processingType)) {
throw new \RuntimeException("Missing null type: for nullable column: " . $column->getName());
}
}
Assertion::implementsInterface($processingType, 'Prooph\\Processing\\Type\\Type');
return $processingType;
}
示例9: convertDoctrineTypeToString
protected function convertDoctrineTypeToString(Column $column, $isPrimary)
{
$type = SerializeTrait::getTypeByDoctrineType($column->getType());
$name = $column->getName();
switch ($type) {
case TableInterface::TYPE_BIGINT:
$result = <<<PHP
\t\t\t'{$name}' => self::TYPE_BIGINT
PHP;
break;
case TableInterface::TYPE_BLOB:
$result = <<<PHP
\t\t\t'{$name}' => self::TYPE_BLOB
PHP;
break;
case TableInterface::TYPE_BOOLEAN:
$result = <<<PHP
\t\t\t'{$name}' => self::TYPE_BOOLEAN
PHP;
break;
case TableInterface::TYPE_DATETIME:
$result = <<<PHP
\t\t\t'{$name}' => self::TYPE_DATETIME
PHP;
break;
case TableInterface::TYPE_DATE:
$result = <<<PHP
\t\t\t'{$name}' => self::TYPE_DATE
PHP;
break;
case TableInterface::TYPE_DECIMAL:
$result = <<<PHP
\t\t\t'{$name}' => self::TYPE_DECIMAL
PHP;
break;
case TableInterface::TYPE_FLOAT:
$result = <<<PHP
\t\t\t'{$name}' => self::TYPE_FLOAT
PHP;
break;
case TableInterface::TYPE_INT:
$result = <<<PHP
\t\t\t'{$name}' => self::TYPE_INT
PHP;
break;
case TableInterface::TYPE_SMALLINT:
$result = <<<PHP
\t\t\t'{$name}' => self::TYPE_SMALLINT
PHP;
break;
case TableInterface::TYPE_TEXT:
$result = <<<PHP
\t\t\t'{$name}' => self::TYPE_TEXT
PHP;
break;
case TableInterface::TYPE_ARRAY:
$result = <<<PHP
\t\t\t'{$name}' => self::TYPE_ARRAY
PHP;
break;
case TableInterface::TYPE_OBJECT:
$result = <<<PHP
\t\t\t'{$name}' => self::TYPE_OBJECT
PHP;
break;
case TableInterface::TYPE_TIME:
$result = <<<PHP
\t\t\t'{$name}' => self::TYPE_TIME
PHP;
break;
case TableInterface::TYPE_VARCHAR:
default:
$result = <<<PHP
\t\t\t'{$name}' => self::TYPE_VARCHAR
PHP;
break;
}
if ($column->getAutoincrement()) {
$result .= ' | self::AUTO_INCREMENT';
}
if ($isPrimary) {
$result .= ' | self::PRIMARY_KEY';
}
return $result . ',';
}
示例10: prepareColumnData
/**
* @param \Doctrine\DBAL\Schema\Column $column The name of the table.
* @param array $primaries
*
* @return array The column data as associative array.
*/
public function prepareColumnData($column, $primaries = array())
{
$columnData = array();
$columnData['name'] = $column->getQuotedName($this);
$columnData['type'] = $column->getType();
$columnData['length'] = $column->getLength();
$columnData['notnull'] = $column->getNotNull();
$columnData['fixed'] = $column->getFixed();
$columnData['unique'] = false;
// TODO: what do we do about this?
$columnData['version'] = $column->hasPlatformOption("version") ? $column->getPlatformOption('version') : false;
if (strtolower($columnData['type']) == "string" && $columnData['length'] === null) {
$columnData['length'] = 255;
}
$columnData['unsigned'] = $column->getUnsigned();
$columnData['precision'] = $column->getPrecision();
$columnData['scale'] = $column->getScale();
$columnData['default'] = $column->getDefault();
$columnData['columnDefinition'] = $column->getColumnDefinition();
$columnData['autoincrement'] = $column->getAutoincrement();
$columnData['comment'] = $this->getColumnComment($column);
$columnData['platformOptions'] = $column->getPlatformOptions();
if (in_array($column->getName(), $primaries)) {
$columnData['primary'] = true;
}
return $columnData;
}
示例11: isFillableField
/**
* Check if the field is fillable.
*
* @param Column $column
* @return bool
*/
protected function isFillableField(Column $column)
{
$fields = array_merge($this->timestamps, [$this->deletedAtColumn], $this->ignoredFillable);
return !$column->getAutoincrement() && !in_array($column->getName(), $fields);
}
示例12: isHidden
/**
* @param Column $column
* @return bool
*/
public function isHidden(Column $column)
{
return $column->getAutoincrement() || $this->hasCommentTag($column, self::HASH_TAG_HIDDEN);
}
示例13: colConfig
/**
* @param Column $col
* @return array
*/
protected function colConfig(Column $col)
{
$conf = [];
//var_dump($col->toArray()); //, $col->getType()->getTypesMap());
$fieldClass = self::$dbType2FieldClass[$col->getType()->getName()];
$fieldName = $col->getName();
if ($col->getAutoincrement()) {
$fieldClass = 'Auto';
} elseif (substr($col->getName(), -3) === '_id') {
$fieldClass = 'ForeignKey';
$fk_tbl = substr($col->getName(), 0, strpos($col->getName(), '_id'));
$fieldName = $fk_tbl;
$conf['relationClass'] = $this->table2model($fk_tbl);
$conf['db_column'] = $col->getName();
if (!isset($this->generated[$fk_tbl])) {
$this->generateQueue[] = $fk_tbl;
}
}
array_unshift($conf, $fieldClass);
if ($this->dp->getReservedKeywordsList()->isKeyword($col->getName())) {
$conf['db_column'] = 'f_' . $col->getName();
}
if ($col->getNotnull() === false) {
$conf['null'] = true;
}
if ($col->getLength() !== null) {
$conf['max_length'] = $col->getLength();
}
if ($col->getDefault() !== null) {
if ($col->getDefault() !== 'CURRENT_TIMESTAMP') {
$conf['default'] = $col->getType()->convertToPHPValue($col->getDefault(), $this->dp);
if ($conf['default'] === '') {
$conf['blank'] = true;
}
}
}
if ($col->getComment() !== null) {
$help = $col->getComment();
if (strpos($help, PHP_EOL) !== false) {
$help = str_replace(PHP_EOL, '', $help);
}
$conf['help_text'] = $help;
}
return [$fieldName, $conf];
}