Types 不接受原则1.2+浮动值。似乎只有整数起作用

Types 不接受原则1.2+浮动值。似乎只有整数起作用,types,doctrine,Types,Doctrine,下面是基类的一个片段: $this->hasColumn('order_total', 'float', null, array( 'type' => 'float', 'fixed' => false, 'unsigned' => false, 'primary' => false, 'notnull' => true, 'autoincrement'

下面是基类的一个片段:

$this->hasColumn('order_total', 'float', null, array(
         'type' => 'float',
         'fixed' => false,
         'unsigned' => false,
         'primary' => false,
         'notnull' => true,
         'autoincrement' => false,
         ));
下面是我的用法:

public function preInsert($event)
{    
    echo $total = $this->_totalWithTax;

    $this->order_total = $total;

    $this->created_at = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
}
出于某种原因,它只在$total为整数时有效,但在其值为浮点时不起作用,顺便说一句,这是最常见的情况。我通过类型转换测试了这个

我徒劳地试图去理解为什么会这样,我已经到了发疯的地步

另外,使用$this->u set'order\u total',$total;也不行

编辑:我忘了提到我在类中有一个getter重写:

public function getOrderTotal()
{
    return $this->_totalWithTax;
} 
以防它真的会有很大的不同

调用save方法时,出现以下错误:

Validation failed in class LP_Orders 1 field had validation error: * 1 validator failed on order_total (notnull)

我遗漏了什么吗?

你能试试这个吗:

$this->hasColumn('order_total', 'float', null, array(
         'type' => 'float',
         'scale' => 8,
         'fixed' => false,
         'unsigned' => false,
         'primary' => false,
         'notnull' => true,
         'autoincrement' => false,
         ));

试过了。不幸的是,它无法修复。然后我想你们应该尝试使用十进制,但也许你们应该放大数值。我已经按照你们的建议将它设置为十进制,但它也无法修复它。顺便说一句,我用可能重要的附加信息编辑了这个问题。谢谢你们两位的时间。你们能给出sql上的订单总数字段类型吗?你确定是双倍的吗?你能写下例外条款吗?用例外条款更新了问题。order_total在数据库中是浮动的。