2011-05-13 81 views
4

我有以下功能:奇怪的PHP錯誤:功能不承認自己的參數

public function updateCustomerInternetBanking($value, $column_to_go_by) 
    { 
    $sql = " 
     UPDATE customer c 
     JOIN account_import ai ON c.account_import_id = ai.id 
     JOIN generic_import gi ON ai.generic_import_id = gi.id 
     JOIN import_bundle ib ON gi.import_bundle_id = ib.id 
     SET has_internet_banking = 1 
     WHERE c.".$column_to_go_by." = ".$this->quote($value)." 
     AND ib.id = ".$this->quote($this->getId())." 
    "; 

    $conn = Doctrine_Manager::connection(); 
    $conn->execute($sql); 
    } 

當我嘗試在開發運行它,它工作正常。當我嘗試在生產環境中運行它,我得到這個:

PHP Notice: Undefined variable: column_to_go_by in /var/www/mcif/lib/model/doctrine/ImportBundle.class.php on line 655 

怎麼能$column_to_go_by是不確定的?

而只是讓你知道,這段代碼是直接從生產複製我檢查了WHERE ......行是第655

+0

那麼,你在哪裏定義了這個變量? :))在調用這個函數 – 2011-05-13 20:03:52

+0

'$ column_to_go_by'中填充了什麼樣的值? – 2011-05-13 20:04:03

+1

開發和生產之間的PHP版本和錯誤處理配置是否相同? – mellamokb 2011-05-13 20:04:29

回答

1

你確定正確地傳遞兩個變量?

一個方法調用這樣的:

updateCustomerInternetBanking(999);

會產生這種錯誤。

+0

這正是發生的事情。我有一箇舊版本的某個文件,因爲我已經重命名了。當我開始生產時,該文件永遠不會被刪除,並且由於類名保持不變,文件被自動加載。這個舊文件使用錯誤的參數數目調用'updateCustomerBanking()'。 – 2011-05-13 20:29:05

+0

不錯,認爲如果你沒有通過一個沒有默認值的參數,它會給出一個致命的錯誤。但這只是PHP中的一個警告。 – meze 2011-05-13 20:33:38