doutao1282 2011-04-24 11:52
浏览 35

尝试使用数据库中的ckeip和codeigniter更新数据

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;
        }
    ?>

</div>


<script type="text/javascript">

$(document).ready(function(){

    $('#editable').ckeip({
    e_url: 'site/abc',
    });



});// enf of the document ready function

  • 写回答

1条回答 默认 最新

  • duandu1377 2011-04-24 15:42
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错