0
我正在使用zend框架。 我想定義產品名稱是否存在,如果沒有則插入產品名稱。如何在zend中使用db-table在數據庫中定義表記錄是否存在或不存在
我在控制器
$this->product_tbl = new Application_Model_DbTable_Producttbl();
$product_name = 'mobile';
$productresult = $this->product_tbl->fetchRow($this->product_tbl->select()->where('product_name ='.$product_name));
if(!$productresult){
// do when productresult is null
}
Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'mobile' in 'where clause'
我的問題是如果product_name
未找到則顯示一個簡單的消息「行未找到」
你能否提供你的表的結構......'product_name'和'mobile'都是列嗎? – coolguy
謝謝,但我解決了我的問題.. –
'product_name'是表的字段,$ proudct_name是可變的 –