Zend Framework中insert時是組合的?小弟我的sql一直有有關問題。supportsParameters是什麼意思
來源:互聯網
上載者:User
Zend Framework中insert時是組合的?我的sql一直有問題。supportsParameters是什麼意思?
我在Controller中:
$table = new Model_Users();
$dd = array('username'=>$username,'password'=>md5($password),'name'=>$name,'email'=>$email,
'reg_time'=>date("Y-m-d H:m:s",time()),'ipaddr'=>$_SERVER['REMOTE_ADDR']);
$test = $table->insert($dd);
然後一直有錯誤,我跟蹤後發現在zend_db_adapter_abstract 中的public function insert($table, array $bind) 中我的sql
在$this->supportsParameters('positional') 時全部把表中的值設為了“?”,請問這個函數的意思是什嗎?
是不是資料庫的配置的問題?
代碼:zend_db_adapter_abstract 中549cell.
------解決方案--------------------
你先查看 $this->supportsParameters('positional') 返回的值
最好貼出了來
再檢查你準備賦值的變數是否與 ? 個數一致,賦值時的變數名是否與對應的欄位名一致
------解決方案--------------------
1.根據你的Db Adapter, ZendDB有可能是調用了mysqli 或者 pdo mysql, 這兩個擴充裡都有bind操作的函數,然後代碼就運行到了該函數的c部分啊
2.不是error-log,是mysql的log, 一般來說my.cnf裡可能沒有開啟,
參看這裡: http://www.howtogeek.com/howto/database/monitor-all-sql-queries-in-mysql/
探討
樓上,謝謝,順利解決,通過try catch,這裡有兩個問題不太明白,望指教!
1. 這裡是怎麼條用底層的c的?可有簡單的例子?
2. 我去mysql中找log,show error-log,但我這裡好像什麼都看不見?
謝謝!