12
我使用下面的代碼,其中$查詢是用教條查詢生成器生成的查詢處理提交的Zend形式更新學說記錄:常規錯誤:與學說2.1和Zend表格1366不正確的整數值更新
$record_array = $query->getResult();
$this->_record = $record_array[0];
if($this->getRequest()->isPost())
{
if ($this->_form->isValid($this->_request->getPost()))
{
$newEntity = $this->_form->update($this->_record);
$this->_em->flush();
$this->view->success = 'Record Saved.';
} else {
$this->view->errors = $this->_form->getErrors();
}
}
上述工作正常,如果沒有記錄中的整數,即只有字符串。但是,如果我在表單中包含字段,並將其映射爲教義實體中的整數,則會出現上述錯誤。
任何幫助,將不勝感激。
UPDATE:
/**
* @var integer $solicitorid
*
* @Column(name="SolicitorID", type="integer", nullable=false)
* @Id
* @GeneratedValue(strategy="IDENTITY")
*/
private $solicitorid;
/**
* @var string $solicitor
*
* @Column(name="Solicitor", type="string", length=160, nullable=true)
*/
private $solicitor;
/**
* @var string $address
*
* @Column(name="Address", type="string", length=160, nullable=true)
*/
private $address;
/**
* @var string $town
*
* @Column(name="Town", type="string", length=100, nullable=true)
*/
private $town;
/**
* @var string $county
*
* @Column(name="County", type="string", length=100, nullable=true)
*/
private $county;
/**
* @var string $postcode
*
* @Column(name="Postcode", type="string", length=100, nullable=true)
*/
private $postcode;
/**
* @var string $dxaddress
*
* @Column(name="DXAddress", type="string", length=150, nullable=true)
*/
private $dxaddress;
/**
* @var string $phone
*
* @Column(name="phone", type="string", length=30, nullable=true)
*/
private $phone;
/**
* @var string $fax
*
* @Column(name="fax", type="string", length=30, nullable=true)
*/
private $fax;
/**
* @var string $email
*
* @Column(name="email", type="string", length=255, nullable=true)
*/
private $email;
/**
* @var string $password
*
* @Column(name="password", type="string", length=30, nullable=false)
*/
private $password;
/**
* @var integer $leadStatus
*
* @Column(name="lead_status", type="integer", nullable=true)
*/
private $leadStatus;
/**
* @var string $termsref
*
* @Column(name="termsRef", type="string", length=10, nullable=true)
*/
private $termsref;
/**
* @var integer $termsconditions
*
* @Column(name="termsconditions", type="integer", nullable=true)
*/
private $termsconditions;
/**
* @var date $termssent
*
* @Column(name="termsSent", type="date", nullable=true)
*/
private $termssent;
/**
* @var date $termssigneddate
*
* @Column(name="termssigneddate", type="date", nullable=true)
*/
private $termssigneddate;
/**
* @var integer $paymentterms
*
* @Column(name="paymentterms", type="integer", nullable=true)
*/
private $paymentterms;
/**
* @var integer $discountterms
*
* @Column(name="discountterms", type="integer", nullable=true)
*/
private $discountterms;
/**
* @var float $discountrate
*
* @Column(name="discountrate", type="float", nullable=true)
*/
private $discountrate;
/**
* @var integer $accountscontact
*
* @Column(name="AccountsContact", type="integer", nullable=true)
*/
private $accountscontact;
/**
* @var date $warned
*
* @Column(name="warned", type="date", nullable=true)
*/
private $warned;
/**
* @var float $feerate
*
* @Column(name="FeeRate", type="float", nullable=true)
*/
private $feerate;
/**
* @var string $labourrate
*
* @Column(name="LabourRate", type="string", length=100, nullable=true)
*/
private $labourrate;
/**
* @var text $specialinst
*
* @Column(name="SpecialInst", type="text", nullable=true)
*/
private $specialinst;
/**
* @var text $reportinst
*
* @Column(name="ReportInst", type="text", nullable=true)
*/
private $reportinst;
/**
* @var boolean $autostatement
*
* @Column(name="AutoStatement", type="boolean", nullable=true)
*/
private $autostatement;
/**
* @var datetime $lastmodifed
*
* @Column(name="lastModifed", type="datetime", nullable=false)
*/
private $lastmodifed;
以上就是實體。 當我嘗試更新整數字段時出現問題。
它沒有包含strict_trans_tables,並且您的建議將其關閉。 這實際上有什麼影響,爲什麼它應該在第一位呢? – Quanano 2012-01-17 14:20:36
這非常準確:「在非嚴格模式下,MySQL服務器將錯誤的輸入值轉換爲最接近的合法值(如列定義所確定的)並繼續運行。例如,如果您嘗試將負值存儲到一個UNSIGNED列,MySQL將它轉換爲零,這是該列最接近的合法值。「在嚴格模式下,它會直接跳過這些轉換並拋出你所看到的錯誤。也許你可以發佈你試圖更新的實體的映射,以及你在表單中發送給它的實際數據 – jere 2012-01-17 14:29:58