我需要将 Symfony2 与我们的 MSSQL 服务器连接起来。
我们已经在 Ubuntu 中使用 PHP 5.3 和 pdo_dblib 安装了 Apache,所以我按照说明安装了 bundle LSWDoctrinePdoDblib
我的 app/config/config.yml 看起来像:
# Doctrine Configuration
doctrine:
dbal:
#driver: %database_driver%
driver_class: Lsw\DoctrinePdoDblib\Doctrine\DBAL\Driver\PDODblib\Driver
host: %database_host%
#host: mssql_freetds
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: %kernel.root_dir%/data/data.db3
# path: %database_path%
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
还有我的 app/config/parameters.yml(带有假数据):
parameters:
database_driver: pdo_dblib
database_host: 10.0.0.33
database_port: '1433'
database_name: DB_CONECTAR
database_user: user_dba
我一直按照此处的说明以及运行命令时:
php app/console doctrine:mapping:convert xml ./src/DBP/GestionWSBundle/Resources/config/doctrine --from-database --force
然后我得到下一个错误,但那里的 SQL 显示工作正常。
[Doctrine\DBAL\DBALException]
An exception occurred while executing 'SELECT col.name,
type.name AS type,
col.max_length AS length,
~col.is_nullable AS notnull,
def.definition AS [default],
col.scale,
col.precision,
col.is_identity AS autoincrement,
col.collation_name AS collation
FROM sys.columns AS col
JOIN sys.types AS type
ON col.user_type_id = type.user_type_id
JOIN sys.objects AS obj
ON col.object_id = obj.object_id
LEFT JOIN sys.default_constraints def
ON col.default_object_id = def.object_id
AND col.object_id = def.parent_object_id
WHERE obj.type = 'U'
AND obj.name = 'MAILING_LISTS'':
SQLSTATE[HY000]: General error: 4004 General SQL Server error: Check messages from the SQL Server [4004] (severity 16) [SELECT col.name,
type.name AS type,
col.max_length AS length,
~col.is_nullable AS notnull,
def.definition AS [default],
col.scale,
col.precision,
col.is_identity AS autoincrement,
col.collation_name AS collation
FROM sys.columns AS col
JOIN sys.types AS type
ON col.user_type_id = type.user_type_id
JOIN sys.objects AS obj
ON col.object_id = obj.object_id
LEFT JOIN sys.default_constraints def
ON col.default_object_id = def.object_id
AND col.object_id = def.parent_object_id
WHERE obj.type = 'U'
AND obj.name = 'MAILING_LISTS']
知道我能做什么吗?非常感谢您提前!!
正如我所提到的,我正在使用https://github.com/LeaseWeb/LswDoctrinePdoDblib正如您可以在网站末尾看到的那样,他尝试做同样的事情并做到了:
- 将任何不兼容的列类型映射到字符串
- 破解 Doctrine 核心以跳过任何没有主键的表
你知道我该怎么做吗?我什至不知道如何查找该信息。