删除查询codeigniter上的num_rows

时间:2016-05-29 17:10:54

标签: php mysql codeigniter

我正在尝试找到一种方法来验证我的删除查询是否成功。如何从以下结构中获取num_rows或affected_rows:

def saveFile(self):   # saving argument values in a filedata
    self.text = QtGui.QTextEdit(self)
    filename = QtGui.QFileDialog.getSaveFileName(self, 'Save File', os.getenv('HOME'))
    f = open(filename, 'w')
    filedata = self.textEdit1.toPlainText()
    filedata = str(filedata)+"\n"
    f.write(filedata)
    filedata = self.textEdit2.toPlainText()
    filedata = str(filedata)+"\n"
    f.write(filedata)
    filedata = self.textEdit3.toPlainText()
    filedata = str(filedata)+"\n"
    f.write(filedata)
    f.close()

使用codeigniter 3

2 个答案:

答案 0 :(得分:2)

测试删除查询使用的结果

$this->db->affected_rows();

答案 1 :(得分:0)

试试这个

public function fire_db($currentUserID, $id_staff){
    $this->db->where('id_player', $currentUserID);
    $this->db->where('id_hired_staff', $id_staff);
    $this->db->limit(1); 

    if (!$this->db->delete('game_hired_staff')) {
        return false;
    }
    else
        print_r($this->db->affected_rows());            
    }
  

codeigniter db->delete() returns true always?

可能重复