dongzhuxun5136 2012-01-16 00:31
浏览 63
已采纳

常规错误:1366 Doctrine 2.1和Zend Form更新时的整数值不正确

I am processing a submitted Zend Form which updates a Doctrine Record using the following code, where $query is a query built using a doctrine query builder:

$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();
        }        
    }

The above works fine if there are no integers in the record, i.e. only strings. However, I get the error above if I include fields on the form which are mapped as integers in the doctrine entity.

Any help would be appreciated.

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;

Above is the entity. The issue comes when I try to update an integer field.

  • 写回答

1条回答 默认 最新

  • dscrb00804 2012-01-16 15:44
    关注

    are you using MySQL? this can happen because MySQL is running in strict mode. run these queries from phpMyAdmin or whatever db administrator you are using to check if the database is in strict mode:

    SELECT @@GLOBAL.sql_mode;
    SELECT @@SESSION.sql_mode;
    

    if it returns something containing STRICT_TRANS_TABLES you could try and run:

    SET @@global.sql_mode= 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?