doumu1873 2010-02-24 18:07
浏览 18
已采纳

为什么Doctrine无法检索我的模型数据?

So, I'm trying to use Doctrine to retrieve some data. I have some basic code like this:

$conn = Doctrine_Manager::connection(CONNECTION_STRING);
$site = Doctrine_Core::getTable('Site')->find('00024');
echo $site->SiteName;

However, this keeps throwing a SQL error that 'column siteid does not exist'. When I look at the exception the SQL query is this (you can see the error is that the inner_tbl alias for siteid is set to s__siteid, so querying inner_tabl.siteid is what's broken):

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] 

Why is the query being generated this way? Could it be the way the Yaml schema is laid out?

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
  • 写回答

1条回答 默认 最新

  • dongyu4908 2010-03-02 03:27
    关注

    I spoke to one of the developers (Johnathan Wage) in the IRC room and he says that SQL may work, but that there are probably bugs (I'm assuming this is one). He also said that Doctrine was written specifically with MySQL in mind.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀