Trying to update data using ckeip and codeigniter in database
Hi i am trying to update my existing data in my database using ckeip jquery plugin in codeigniter. I am able to update my data in the database. but when i refresh my page, the database field again shows the value of zero. i dont know y it is happenig.
Can you please explain that.. if i have another div to update using ckeip than how i should tel php script to update only this particular script
Thanks
=================here is the my model code==================
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);
}
==================here is my controller code===============
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');
}
==================this is my view file code================
<div id="editable" name="sample">
<?php
foreach($paste as $row){
echo $row->content;
}
?>
</d开发者_如何学Goiv>
<script type="text/javascript">
$(document).ready(function(){
$('#editable').ckeip({
e_url: 'site/abc',
});
});// enf of the document ready function
I don't know the first thing about CodeIgniter or the underlying database library, but...
$this->db->where('id', 1);
$this->db->update('about', $up_data);
... seems kind of wrong. This looks like a query builder. Don't you need to chain the WHERE
clause off of the UPDATE
clause? Something like
$this->db->update('about', $up_data)->where('id', 1);
might work for you.
You could probably have found this out yourself with the most basic forms of troubleshooting, like echoing the new expected value, or querying the database after the update to ensure the update worked, or even breaking out a debugger.
精彩评论