代码之家  ›  专栏  ›  技术社区  ›  scottm

为什么不能检索我的模型数据?

  •  2
  • scottm  · 技术社区  · 16 年前

    所以,我试着用条令来检索一些数据。我有一些基本代码如下:

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

    但是,这会不断抛出“column siteid does not exist”的SQL错误。当我查看异常时,SQL查询是这样的(您可以看到错误是siteid的内部\u tbl别名被设置为s \u siteid,因此查询内部\u 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
    
    1 回复  |  直到 16 年前
        1
  •  0
  •   scottm    16 年前

    我在IRC室和一个开发人员(Johnathan Wage)谈过,他说SQL可以工作,但是可能有bug(我假设这是一个bug)。他还说,这一学说是专门为MySQL编写的。

    推荐文章