【发布时间】:2017-12-01 09:07:00
【问题描述】:
大家好,
我对 Symfony 2 和 Doctrine 的 MSSQL 数据库有疑问。在“php app/console 学说:数据库:创建”和“php app/console 学说:schema:create”上都很好。但是在“php app/console dictionary:schema:update”上,ORM-Mapper 或实体显示没有任何变化,出现以下错误:
[Doctrine\DBAL\DBALException]
An exception occurred while executing 'ALTER TABLE product DROP CONSTRAINT DF_D34A04AD_A5D6E63E':
SQLSTATE[42000]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]DF_D34A04AD_A5D6E63E is not a restriction.
请帮忙
当我从名为“DF__product__timesta__38996AB5”的表中手动删除限制时,这是一个新错误:
[Doctrine\DBAL\DBALException]
An exception occurred while executing 'ALTER TABLE product ALTER COLUMN timestamp DATETIME DEFAULT CURRENT_TIMESTAMP':
SQLSTATE[42000]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Incorrect syntax near the DEFAULT keyword.
请帮忙
数据库
Microsoft SQL Server 2016
PHP 包:
php70.x86_64 1.0-5.el7
php70-php.x86_64 7.0.26-1.el7
php70-php-cli.x86_64 7.0.26-1.el7
php70-php-common.x86_64 7.0.26-1.el7
php70-php-json.x86_64 7.0.26-1.el7
php70-php-pdo.x86_64 7.0.26-1.el7
php70-php-sqlsrv.x86_64 4.3.0-1.el7
php70-php-xml.x86_64 7.0.26-1.el7
php70-runtime.x86_64 1.0-5.el7
parameters.yml
database_driver: sqlsrv
src/AppBundle/Entity/Product.php 命名空间 AppBundle\Entity;
class Product
{
private $name;
private $price;
private $description;
private $timestamp;
}
src/AppBundle/Resources/config/doctrine/Product.orm.yml
AppBundle\Entity\Product:
type: entity
table: product
id:
id:
type: integer
generator: { strategy: AUTO }
fields:
name:
type: string
length: 100
price:
type: decimal
scale: 2
description:
type: test
timestamp:
type: datetime
columnDefinition: DATETIME DEFAULT CURRENT_TIMESTAMP
nullable: false
table panel.product的导出结构
CREATE TABLE IF NOT EXISTS "product" (
"id" INT(10,0) NOT NULL,
"name" NVARCHAR(100) NOT NULL,
"price" NUMERIC(10,2) NOT NULL,
"description" VARCHAR(max) NOT NULL,
"timestamp" DATETIME(3) NULL DEFAULT (getdate()),
PRIMARY KEY ("id")
);
作曲家表演-i
doctrine/annotations v1.2.6 Docblock Annotations Parser
doctrine/cache v1.4.1 Caching library offering an object-oriented API for many cache backends
doctrine/collections v1.3.0 Collections Abstraction library
doctrine/common v2.5.0 Common Library for Doctrine projects
doctrine/dbal v2.4.4 Database Abstraction Layer
doctrine/doctrine-bundle v1.5.0 Symfony DoctrineBundle
doctrine/doctrine-cache-bundle v1.0.1 Symfony2 Bundle for Doctrine Cache
doctrine/inflector v1.0.1 Common String Manipulations with regard to casing and singular/plural rules.
doctrine/lexer v1.0.1 Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
doctrine/orm v2.4.7 Object-Relational-Mapper for PHP
incenteev/composer-parameter-handler v2.1.1 Composer script handling your ignored parameter file
jdorn/sql-formatter v1.2.17 a PHP SQL highlighting library
kriswallsmith/assetic v1.2.1 Asset Management for PHP
monolog/monolog 1.15.0 Sends your logs to files, sockets, inboxes, databases and various web services
psr/log 1.0.0 Common interface for logging libraries
sensio/distribution-bundle v4.0.0 Base bundle for Symfony Distributions
sensio/framework-extra-bundle v3.0.9 This bundle provides a way to configure your controllers with annotations
sensio/generator-bundle v2.5.3 This bundle generates code for you
sensiolabs/security-checker v2.0.5 A security checker for your composer.lock
swiftmailer/swiftmailer v5.4.1 Swiftmailer, free feature-rich PHP mailer
symfony/assetic-bundle v2.6.1 Integrates Assetic into Symfony2
symfony/monolog-bundle v2.7.1 Symfony MonologBundle
symfony/swiftmailer-bundle v2.3.8 Symfony SwiftmailerBundle
symfony/symfony v2.6.11 The Symfony PHP framework
twig/extensions v1.2.0 Common additional features for Twig that do not directly belong in core
twig/twig v1.18.2 Twig, the flexible, fast, and secure template language for PHP
【问题讨论】:
标签: php sql-server symfony doctrine sqlsrv