1

通过 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)

我不明白这个验证错误!这些字段类型是浮点数,这里会发生什么?

架构.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
    (...)

更奇怪的是,我在生产环境中有错误,而不是在 localhost :(

编辑:在 BaseDataPerDayFormFilter.class.php 中,验证器是:

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

这个可以吗 ?

4

1 回答 1

0

错误不在 schema.yml 中,而是在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

我不知道这个“ validate: all”是从哪里来的,但正是它造成了这些错误。

于 2012-04-24T12:29:52.973 回答