2012-01-16 10 views
12

sto elaborando uno Zend modulo presentato che aggiorna un record Dottrina utilizzando il seguente codice, dove $ query è una query costruita utilizzando un generatore di query dottrina:Errore generale: 1366 valore intero non corretto con Dottrina 2.1 e Zend modulo di aggiornamento

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

Quanto sopra funziona bene se non ci sono interi nel record, cioè solo stringhe. Tuttavia, ottengo l'errore sopra se includo campi nel modulo che sono mappati come numeri interi nell'entità doctrine.

Qualsiasi aiuto sarebbe apprezzato.

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; 

è al di sopra l'entità. Il problema si presenta quando provo ad aggiornare un campo intero.

risposta

29

stai usando MySQL? questo può accadere perché MySQL è in esecuzione in modalità rigorosa. gestiscono queste richieste da phpMyAdmin o qualunque amministratore di db che si utilizza per verificare se il database è in modalità rigorosa:

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

se restituisce qualcosa contenente STRICT_TRANS_TABLES si potrebbe provare ed eseguire:

SET @@global.sql_mode= 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; 
+0

Ha fatto contiene strict_trans_tables e il tuo suggerimento lo ha disattivato. Che effetto ha effettivamente questo, perché dovrebbe essere stato attivo in primo luogo? – Quanano

+0

questo è abbastanza preciso: "In modalità non rigida, il server MySQL converte i valori di input errati nei valori legali più vicini (come determinato dalle definizioni di colonna) e continua nel suo modo. Ad esempio, se si tenta di memorizzare un valore negativo in una colonna UNSIGNED, MySQL lo converte a zero, che è il valore legale più vicino per la colonna. " in modalità rigorosa salterà direttamente quelle conversioni e genererà quell'errore che stai vedendo. forse puoi pubblicare la mappatura dell'entità che stai tentando di aggiornare e i dati effettivi che stai inviando nel modulo – jere

Problemi correlati