简体   繁体   中英

How to write update set in zend db?

Please Suggest me how to write this using zend db

$userId = $_GET ['user_id'];
$statsFalg = $_GET['stats_flag'];
$query = UPDATE users SET stats_flag='".$statsFlag."' WHERE user_id='".$userId."';

Actually I'm sending an request through Ajax when the user checked box or unchecked a box

Do something like this in the update function of your model:

$data = array(
    'stats_flag' => 0,
);
$this->getDbTable()->update($data, array('user_id = ?' => $userId));

Where getDbTable() returns an instance of Zend_Db_Table_Abstract :

class Application_Model_DbTable_User extends Zend_Db_Table_Abstract
{
    protected $_schema = 'test';
    protected $_name = 'user';  
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM