我將我的項目切換到PDO,並遇到以下代碼的問題。它不會拋出錯誤,但也不會插入到數據庫中。我一直在讀PDO,我已經看過DebugdumpParams()
。我加了$result->debugDumpParams()
,頁面沒有加載。PHP PDO查詢問題
我需要在prepare()
之後使用BindParam()
,才能在之前進行調試嗎?
public function CustomerInsert($name, $street1, $street2, $city, $state, $zip, $phone_area, $phone, $email, $notes, $leadtype, $rating, $newsletter, $frequency)
{
$q = "INSERT INTO customers VALUES('', :name , :street1 , :street2 , :city , :state , :zip , :phone_area , :phone , :email , :notes , :newsletter , :leadtype , :frequency)";
try{
$result = $this->connection->prepare($q);
$result->execute(array(':name'=>$name, ':street1'=>$street1, ':street2'=>$street2,
':city'=>$city, ':state'=>$state, ':zip'=>$zip, ':phone_area'=>$phone_area,
':phone'=>$phone, ':email'=>$email, ':notes'=>$notes, ':newsletter'=>$newsletter,
':leadtype'=>$leadtype, ':frequency'=>$frequency));
}
catch (PDOException $e)
{
throw new Exception('Connection failed: ' . $e->getMessage());
}
打開錯誤報告上 – 2013-04-10 15:09:51
怎麼辦我這樣做?在PHP中報告錯誤?是否有可能在每個文件的基礎上做到這一點? – XanderNGCC 2013-04-10 15:10:58
也看看'$ result-> ErrorInfo()'和'$ this-> connection-> ErrorInfo()' – andrewsi 2013-04-10 15:11:35