How to know mysql Error in zend
I have following query in my project,
$values = array("test"=>"value")
$this->_db->update("tablename",$values,array('id = ?'=> $data['id'],'wid = ?'=> $data['WId']));
If i execute first time i got 开发者_开发技巧updated with values, if i did second time, Sql error will be something like "0 rows affected
" . So here I need to know that exception in zend framwork. Kindly help me
Going from the comments, I think you need to use:
$rowsAffected = $this->_db->update("tablename",$values,array('id = ?'=> $data['id'],'wid = ?'=> $data['WId']));
$rowsAffected
will give you the number of rows affected. So if its 0
, output your message.
Zend_Db_Adapter_Abstract.update(mixed $table, array $bind, mixed $where)
Updates table rows with specified data based on a WHERE clause.
Parameters:
mixed $table The table to update.
array $bind Column-value pairs.
mixed $where UPDATE WHERE clause(s).
Returns:
int The number of affected rows.
Throws:
Zend_Db_Adapter_Exception
精彩评论