【问题标题】:Trying to update data using ckeip and codeigniter in database尝试在数据库中使用 ckeip 和 codeigniter 更新数据
【发布时间】:2011-08-11 20:05:21
【问题描述】:

您好,我正在尝试使用 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

【问题讨论】:

    标签: php jquery mysql codeigniter


    【解决方案1】:

    我不知道 CodeIgniter 或底层数据库的第一件事,但是...

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

    ... 似乎有点不对劲。这看起来像一个查询生成器。您不需要将WHERE 子句与UPDATE 子句链接起来吗?类似的东西

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

    可能对你有用。

    您可能已经通过最基本的故障排除形式自己发现了这一点,例如回显新的预期值,或在更新后查询数据库以确保更新有效,甚至打破调试器。

    【讨论】:

      猜你喜欢
      • 2016-12-29
      • 2019-06-24
      • 2023-04-06
      • 2018-05-05
      • 2015-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多