douhuanbai6729 2012-04-24 09:25
浏览 34
已采纳

为什么我在Symfony 1.4上使用Doctrine进行“验证失败”?

I have the following error while importing some data via Doctrine :

value1:19.022542
value2:497.795
value3:9466.541667
Caught exception: Validation failed in class DataPerDay

  27 fields had validation errors:

    * 1 validator failed on value1 (type)
    * 1 validator failed on value2 (type)
    * 1 validator failed on value3 (type)

I don't understand this validation error !! The fields are of type float, what could be going on here ?

schema.yml :

DataPerDay:
  connection: doctrine
  tableName: xp_data_per_day
  columns:
    id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    inverter_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    (...)
    value1:
      type: float
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    (...)

Weirder still, I have the error on the production environnent, not on localhost :(

EDIT : in BaseDataPerDayFormFilter.class.php, the validators are :

'value1'      => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),

Is this ok ?

  • 写回答

1条回答 默认 最新

  • duanlu1959 2012-04-24 12:29
    关注

    The error was not in schema.yml, but in databases.yml :

    prod:
      doctrine:
        class: sfDoctrineDatabase
        param:
          profiler: false
          dsn: 'mysql:host=xxx.net;dbname=xxx'
          port: 3306
          username: xxx
          password: xxx
          encoding: UTF8
          attributes:
            quote_identifier: false
            use_native_enum: false
            idxname_format: %s_idx
            seqname_format: %s_seq
            tblname_format: %s
            validate: all
    

    I don't know where this "validate: all" came from, but it was what was creating those errors.

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

报告相同问题?

悬赏问题

  • ¥100 iOS开发关于快捷指令截屏后如何将截屏(或从截屏中提取出的文本)回传给本应用并打开指定页面
  • ¥15 unity连接Sqlserver
  • ¥15 图中这种约束条件lingo该怎么表示出来
  • ¥15 VSCode里的Prettier如何实现等式赋值后的对齐效果?
  • ¥15 流式socket文件传输答疑
  • ¥20 keepalive配置业务服务双机单活的方法。业务服务一定是要双机单活的方式
  • ¥50 关于多次提交POST数据后,无法获取到POST数据参数的问题
  • ¥15 win10,这种情况怎么办
  • ¥15 如何在配置使用Prettier的VSCode中通过Better Align插件来对齐等式?(相关搜索:格式化)
  • ¥100 在连接内网VPN时,如何同时保持互联网连接