2014-02-06 43 views
0

我有一個字段是int,我正在更新字段爲NULL。
這裏是我的代碼used-Zend Framework - 更新int字段爲NULL更新爲0而不是NULL

$db = $Table->getAdapter(); 
    $db->beginTransaction(); 

    try { 
     $db->update('table_name', array('is_approved' => NULL), array('id = ?' => $id)); 
     $document_db->commit(); 
    } catch (Exception $e) { 
     $document_db->rollBack(); 
     throw $e; 
    } 

當我看着場上,它顯示0,而不是空。我在stackoverflow上閱讀了很多相關的問題。一個說要使用嚴格的模式。如何使用Zend啓用嚴格模式。

任何其他解決方法?我需要更新到NULL
在此先感謝。

回答

1
$db = $Table->getAdapter(); 
    $db->beginTransaction(); 

    try { 
     $null = new Zend_Db_Expr("NULL"); 
     $db->update('table_name', array('is_approved' => $null), array('id = ?' => $id)); 
     $document_db->commit(); 
    } catch (Exception $e) { 
     $document_db->rollBack(); 
     throw $e; 
    } 
1

設置它使用的方法:new Zend_Db_Expr('NULL')