【发布时间】:2015-03-04 02:33:10
【问题描述】:
我有一个从数据库中删除的删除按钮。我按下页面上的删除按钮,它不会做任何事情,直到我按下它几次。有时,它只是一次尝试从数据库中删除值,而其他时候,我必须多次按下删除按钮才能将其删除。有什么办法可以克服吗?
我的视图文件:
//other code above
<?php $encrypted = $this->encrypt->encode($data->pid); ?>
<a href="<?php echo base_url() . "profile/delete_entry/" . $encrypted; ?>">Delete</a>
//other code below
我的控制器:
$this->load->model('model_entry');
$pid = $this->uri->segment(3);
$result = $this->model_entry->entry_delete($pid);
//redirect to entries index.php
我的模特
public function entry_delete($pid) {
$pid = $this->encrypt->decode($pid); //to decode
$uid=$this->session->userdata('uid');
$whereConditions = array('pid' => $pid, 'uid' => $uid);
$this->db->where($whereConditions);
$this->db->delete('dayone_entries');
}
【问题讨论】:
-
你加载了 $this->load->library('encrypt'); codeigniter.com/user_guide/libraries/encryption.html 我在 entry_delete 中没有看到它。或者你有没有自动加载它。
-
嘿,我已经自动加载了。
标签: php database codeigniter