Zend framework $db->update result

前端 未结 3 825
礼貌的吻别
礼貌的吻别 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:13

    Maybe:

    $data = array(
        'updated_on'      => '2007-03-23',
    
        'bug_status'      => 'FIXED'
    );
    $result = $db->update('bugs', $data, 'bug_id = 2');
    if ($result < $numRows) {//pass in numRows as method arg or hardcode integer.
        //handle error
    } else {
        return TRUE;
    }
    

    Try something like this with the idea being you want to verify that the number of records you wanted updated got updated.

提交回复
热议问题