Zend framework $db->update result

前端 未结 3 824
礼貌的吻别
礼貌的吻别 2021-01-20 15:34

Zend_Db_Adapter::update() returns the number of rows affected by the update operation. What is best way to determine if the query was successful?



        
3条回答
  •  离开以前
    2021-01-20 16:20

    $data = array(
        'updated_on' => '2007-03-23',
        'bug_status' => 'FIXED',
    );
    $n = 0;
    try {
        $n = $db->update('bugs', $data, 'bug_id = 2');
    } catch (Zend_Exception $e) {
        die('Something went wrong: ' . $e->getMessage());
    }
    if (empty($n)) {
        die('Zero rows affected');
    }
    

提交回复
热议问题