所以,我正在尝试使用Doctrine来检索一些数据。我有一些像这样的基本代码:
$conn = Doctrine_Manager::connection(CONNECTION_STRING);
$site = Doctrine_Core::getTable('Site')->find('00024');
echo $site->SiteName;
但是,这会导致抛出“列siteid不存在”的SQL错误。当我查看异常时,SQL查询是这样的(您可以看到错误是siteid的inner_tbl别名设置为s__siteid,因此查询inner_tabl.siteid是什么被打破):
SELECT TOP 1
[inner_tbl].[siteid] AS [s__siteid]
FROM
(SELECT TOP 1
[s].[siteid] AS [s__siteid],
[s].[name] AS [s__name],
[s].[address] AS [s__address],
[s].[city] AS [s__city],
[s].[zip] AS [s__zip],
[s].[state] AS [s__state],
[s].[region] AS [s__region],
[s].[callprocessor] AS [s__callprocessor],
[s].[active] AS [s__active], [s].[dateadded] AS [s__dateadded]
FROM [Sites] [s]
WHERE ([s].[siteid] = '00024')
) AS [inner_tbl]
为什么查询是以这种方式生成的?这可能是Yaml架构的布局方式吗?
Site:
connection: 0
tableName: Sites
columns:
siteid:
type: string(5)
fixed: true
unsigned: false
primary: true
autoincrement: false
name:
type: string(300)
fixed: false
unsigned: false
notnull: true
primary: false
autoincrement: false
address:
type: string(100)
fixed: false
unsigned: false
notnull: false
primary: false
autoincrement: false
city:
type: string(100)
fixed: false
unsigned: false
notnull: false
primary: false
autoincrement: false
zip:
type: string(5)
fixed: false
unsigned: false
notnull: false
primary: false
autoincrement: false
state:
type: string(2)
fixed: true
unsigned: false
notnull: true
primary: false
autoincrement: false
region:
type: integer(4)
fixed: false
unsigned: false
notnull: true
default: (5)
primary: false
autoincrement: false
callprocessor:
type: integer(4)
fixed: false
unsigned: false
notnull: true
primary: false
autoincrement: false
active:
type: integer(1)
fixed: false
unsigned: false
notnull: true
primary: false
autoincrement: false
dateadded:
type: timestamp(16)
fixed: false
unsigned: false
notnull: true
default: (getdate())
primary: false
autoincrement: false
答案 0 :(得分:0)
我在IRC会议室与其中一位开发人员(Johnathan Wage)交谈,他说SQL可能有效,但可能存在错误(我假设这是一个错误)。他还说,Doctrine是专门针对MySQL编写的。