當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Column::getNotnull方法代碼示例

本文整理匯總了PHP中Doctrine\DBAL\Schema\Column::getNotnull方法的典型用法代碼示例。如果您正苦於以下問題:PHP Column::getNotnull方法的具體用法?PHP Column::getNotnull怎麽用?PHP Column::getNotnull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\DBAL\Schema\Column的用法示例。


在下文中一共展示了Column::getNotnull方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getValidationRules

 public function getValidationRules()
 {
     if (count($this->validationRules) === 0 && $this->noValidate() === false) {
         if ($this->dbal->getNotnull()) {
             $this->validationRules[] = 'required';
         }
     }
     return implode('|', $this->validationRules);
 }
開發者ID:ablunier,項目名稱:crud,代碼行數:9,代碼來源:Field.php

示例2: getSql

 public function getSql(Column $column, $table)
 {
     if (!$table instanceof Table) {
         $table = new Identifier($table);
     }
     $sql = array();
     $normalized = $column->getType()->getNormalizedPostGISColumnOptions($column->getCustomSchemaOptions());
     $srid = $normalized['srid'];
     // PostGIS 1.5 uses -1 for undefined SRID's
     if ($srid <= 0) {
         $srid = -1;
     }
     $type = strtoupper($normalized['geometry_type']);
     if ('ZM' === substr($type, -2)) {
         $dimension = 4;
         $type = substr($type, 0, -2);
     } elseif ('M' === substr($type, -1)) {
         $dimension = 3;
     } elseif ('Z' === substr($type, -1)) {
         $dimension = 3;
         $type = substr($type, 0, -1);
     } else {
         $dimension = 2;
     }
     // Geometry columns are created by the AddGeometryColumn stored procedure
     $sql[] = sprintf("SELECT AddGeometryColumn('%s', '%s', %d, '%s', %d)", $table->getName(), $column->getName(), $srid, $type, $dimension);
     if ($column->getNotnull()) {
         // Add a NOT NULL constraint to the field
         $sql[] = sprintf('ALTER TABLE %s ALTER %s SET NOT NULL', $table->getQuotedName($this->platform), $column->getQuotedName($this->platform));
     }
     return $sql;
 }
開發者ID:novikovsergey,項目名稱:doctrine-postgis,代碼行數:32,代碼來源:SpatialColumnSqlGenerator.php

示例3: __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'));
     }
 }
開發者ID:alanedwardes,項目名稱:carbo,代碼行數:28,代碼來源:ColumnInformation.php

示例4: 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;
 }
開發者ID:jdavis593,項目名稱:appitechture,代碼行數:59,代碼來源:Comparator.php

示例5: 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;
 }
開發者ID:seytar,項目名稱:psx,代碼行數:15,代碼來源:Schema.php

示例6: timestampsAreEqual

 /**
  * Check if dates are the same.
  *
  * @param Column $createdAt
  * @param Column $updatedAt
  * @return bool|string
  */
 protected function timestampsAreEqual(Column $createdAt, Column $updatedAt)
 {
     $check = $createdAt->getDefault() == ($updatedAt->getDefault() == '0000-00-00 00:00:00') && $createdAt->getNotnull() == $updatedAt->getNotnull();
     if ($check) {
         return 'default.' . ($createdAt->getNotnull() ? 'notNull' : 'null');
     }
     return false;
 }
開發者ID:bebnev,項目名稱:laravel-schema-parser,代碼行數:15,代碼來源:SchemaAdapter.php

示例7: 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;
 }
開發者ID:prooph,項目名稱:link-sql-connector,代碼行數:20,代碼來源:TableConnectorGenerator.php

示例8: processBlob

 /**
  * Process blob|binary type of the table field.
  *
  * @param Column $column
  * @param bool $isUnique
  * @return string
  */
 protected function processBlob(Column $column, $isUnique)
 {
     return $this->grammar->binary($column->getName(), $column->getDefault(), !$column->getNotnull(), $isUnique);
 }
開發者ID:bebnev,項目名稱:laravel-schema-parser,代碼行數:11,代碼來源:Processor.php

示例9: isSoftDeletes

 /**
  * Check if column is deleted_at.
  *
  * @param Column $column
  * @return bool
  */
 protected function isSoftDeletes(Column $column)
 {
     return !is_null($this->deletedAtColumn) && $column->getName() === $this->deletedAtColumn && !$column->getNotnull();
 }
開發者ID:bebnev,項目名稱:laravel-schema-parser,代碼行數:10,代碼來源:Compiler.php

示例10: required

 /**
  * @return boolean
  */
 public function required()
 {
     return $this->column->getNotnull();
 }
開發者ID:shin1x1,項目名稱:laravel-table-admin,代碼行數:7,代碼來源:AbstractColumn.php

示例11: populateColumn

 /**
  * Populates attributes.
  *
  * @param   Attrs   $attrs
  * @param   string  $key
  * @param   Column  $column
  */
 private function populateColumn($attrs, $key, $column)
 {
     $attrs->set($this->deriveName($key), ['key' => $key, 'type' => $column->getType()->getName(), 'default' => $column->getDefault(), 'nullable' => !$column->getNotnull()]);
 }
開發者ID:drwrf,項目名稱:mismatch-orm,代碼行數:11,代碼來源:Populator.php

示例12: 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;
     }
 }
開發者ID:GitHubUser4234,項目名稱:core,代碼行數:65,代碼來源:MDB2SchemaWriter.php

示例13: getMinlength

 /**
  * Metodo responsavel por recuperar o maxlength
  *
  * @param Column $objColumn
  * @return int|null
  */
 private function getMinlength($objColumn)
 {
     $intMinLength = 0;
     if ($objColumn->getNotnull()) {
         $intMinLength = 1;
     }
     return $intMinLength;
 }
開發者ID:diego-mi,項目名稱:financeiro,代碼行數:14,代碼來源:GeneratorInputFilterHelper.php

示例14: 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];
 }
開發者ID:buldezir,項目名稱:dja_orm,代碼行數:49,代碼來源:Introspection.php

示例15: formatColumn

 /**
  * @param $column
  * @return array
  */
 protected function formatColumn(Column $column)
 {
     return ['type' => $column->getType()->getName(), 'required' => $column->getNotnull(), 'default' => $column->getDefault()];
 }
開發者ID:quarkcms,項目名稱:connector,代碼行數:8,代碼來源:ColumnsFormatter.php


注:本文中的Doctrine\DBAL\Schema\Column::getNotnull方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。