您好我正在尝试使用codeigniter中的ckeip jquery插件更新我的数据库中的现有数据。我能够更新数据库中的数据。但是当我刷新页面时,数据库字段再次显示零值。我不知道这是不可能的事。
请你解释一下..如果我有另一个div使用ckeip更新比我应该如何tel php脚本只更新这个特定的脚本
由于
=================这是我的型号代码==================
function get(){
$query = $this->db->select('content')->from('about')->where('id', 1)->get();
return $query->result();
}
function update_abx(){
$up_data = array('content' => $this->input->post('content'));
$this->db->where('id', 1);
$this->db->update('about', $up_data);
}
==================这是我的控制器代码===============
function index(){
$data['paste'] = $this->test->get();
$this->load->view('index_view', $data);
}
function abc(){
$query = $this->test->update_abx();
$this->load->view('index_view');
}
==================这是我查看的文件代码================
<div id="editable" name="sample">
<?php
foreach($paste as $row){
echo $row->content;
}
?>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#editable').ckeip({
e_url: 'site/abc',
});
});// enf of the document ready function
答案 0 :(得分:0)
我不知道CodeIgniter或底层数据库库的第一件事,但是......
$this->db->where('id', 1);
$this->db->update('about', $up_data);
......似乎有点不对劲。这看起来像一个查询构建器。您是否需要将WHERE
子句与UPDATE
子句链接起来?像
$this->db->update('about', $up_data)->where('id', 1);
可能适合你。
您可能已经使用最基本的故障排除方式自行找到了这一点,例如回显新的预期值,或者在更新后查询数据库以确保更新有效,甚至打破调试器。