本文介绍了如何测试Ci是否成功插入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Ci中,我有以下函数。如何测试查询是否成功插入没有错误?
In Ci, I've got the following function. How do I test that the query successfully inserted without error's?
public function postToWall() {
$entryData = $this->input->post('entryData');
$myChurchId = $this->session->userdata("myChurchId");
$this->db->query("INSERT IGNORE INTO wallPosts (entryData, entryCreationDateTime, wpChurchId)
VALUES('$entryData', NOW(), '$myChurchId')");
}
推荐答案
$ c> $ this-> db-> affected_rows() codeigniter的函数。
You can use $this->db->affected_rows()
function of codeigniter.
查看更多信息
您可以这样做:
return ($this->db->affected_rows() != 1) ? false : true;
这篇关于如何测试Ci是否成功插入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!