2011-04-24 51 views
1

嗨,我想在codeigniter中使用ckeip jquery插件更新我的數據庫中的現有數據。我能夠更新數據庫中的數據。但是當我刷新我的頁面時,數據庫字段再次顯示零值。我不知道它是不是碰巧。嘗試在數據庫中使用ckeip和codeigniter更新數據

能否請你解釋一下..如果我還有一個DIV使用ckeip比怎麼樣,我應該電話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

我不知道笨或底層數據庫庫的第一件事情,但是......

$this->db->where('id', 1); 
$this->db->update('about', $up_data); 

...似乎有點不對。這看起來像一個查詢生成器。您是否需要連接UPDATE子句中的WHERE子句?類似於

$this->db->update('about', $up_data)->where('id', 1); 

可能適合你。

你也許已經排除故障的最基本的形式發現了這一點你自己,就像在更新後呼應新的預期值,或查詢數據庫,以確保更新的工作,甚至打破了一個調試器。

相關問題