【问题标题】:Yii CDbException.. invalid input syntax for integer: "1,075"Yii CDbException.. 整数的无效输入语法:“1,075”
【发布时间】:2013-08-19 06:14:44
【问题描述】:

我从今天早上开始从生产站点收到此错误,我想知道为什么我在 UAT 或开发人员环境中没有收到相同的错误..

有没有人熟悉这样的错误?

CDbException

Description

CDbCommand failed to execute the SQL statement: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "1,076"

Source File

C:\inetpub\wwwroot\framework1.0\db\CDbCommand.php(372)

00360:             }
00361: 
00362:             if($this->_connection->enableProfiling)
00363:                 Yii::endProfile('system.db.CDbCommand.query('.$this->getText().')','system.db.CDbCommand.query');
00364: 
00365:             return $result;
00366:         }
00367:         catch(Exception $e)
00368:         {
00369:             if($this->_connection->enableProfiling)
00370:                 Yii::endProfile('system.db.CDbCommand.query('.$this->getText().')','system.db.CDbCommand.query');
00371:             Yii::log('Error in querying SQL: '.$this->getText().$par,CLogger::LEVEL_ERROR,'system.db.CDbCommand');
00372:             throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
00373:                 array('{error}'=>$e->getMessage())));
00374:         }
00375:     }
00376: }

还附上截图.. 该应用程序基于 yii 框架和 postgress 数据库。

非常感谢快速回复。

【问题讨论】:

  • 很可能有人在您的一个输入字段中输入了1,076 作为数字,而您将其发送到数据库中。不过,对于 DB,它应该是 1.076。您需要先转换为正确的格式。
  • 或者,很可能是1076;许多人会用千位分隔符写1,123.00(美国/澳大利亚/英国表格)或1.123,00(欧盟表格)之类的东西。 PostgreSQL 不接受带有千位分隔符的整数。
  • @CraigRinger 不,它在我的开发端确实有效。所以我想知道这怎么可能。此外,数字 1,076 有时也会更改为 1064 ......而且这也不会由于用户输入或类型误用而发生......
  • 我同意。这看起来像一个语言环境问题。检查两台服务器上的 PHP 设置以及可用的语言环境。

标签: sql database postgresql yii syntax-error


【解决方案1】:

问题实际上是因为对主键使用了 number_format() 函数,后来在代码部分中,它输入格式化的数字来搜索查询。即从用户中选择 *,其中 id = 1,075(而不是 id = 1075)

将 number_format() 函数更改为仅适用于选定的工作区域。

【讨论】:

    猜你喜欢
    • 2020-03-26
    • 1970-01-01
    • 2021-07-05
    • 1970-01-01
    • 1970-01-01
    • 2022-10-08
    • 1970-01-01
    • 2014-07-17
    • 2015-10-19
    相关资源
    最近更新 更多