Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter 更新codeignaitor中的行时出错_Codeigniter - Fatal编程技术网

Codeigniter 更新codeignaitor中的行时出错

Codeigniter 更新codeignaitor中的行时出错,codeigniter,Codeigniter,将行更新到数据库时出错 我的问题是当我上传pic时没有更新行并打电话给我,更新文件上传未在索引中定义 我的控制器: public function addedit(){ $events = new events_model(); $prodID = $this->input->post('hID'); $text = $this->input->post('ev_text'); $pic = $this->do_upload('ev

将行更新到数据库时出错

我的问题是当我上传pic时没有更新行并打电话给我,更新文件上传未在索引中定义

我的控制器:

public function addedit(){

    $events = new events_model();
    $prodID = $this->input->post('hID');
    $text = $this->input->post('ev_text');
    $pic = $this->do_upload('ev_pic');
    $submit = $this->input->post('submit');

    if($submit){

        if(!empty($prodID)){

            $this->data['events'] = $events->UpdatePost($prodID, $text , $pic );
            $this->data['pagetitle'] = "Show Info";             
            $this->data['success']= "Update Done";

        }else{

            $this->data['success'] = "Add Done";
        }

    $this->data['status'] = "1";

    }else{

        $this->data['status'] = "0";
        $this->data['errors'] = "Error";
    }

    $this->template->build('admin/events/add',$this->data);
}
和型号:

function UpdatePost($prodID, $text , $pic ) {

    if ($pic == ""){

        $vales = array('ev_id' => $prodID , 'ev_text' => $text);

    }else{

        $vales = array('ev_id' => $prodID , 'ev_text' => $text , 'ev_pic' => $pic);
    }

    $query = $this->db->update($this->table_name, $vales) or die (mysql_error());
    $result = array();
    $result["process"] = "ok";
    echo "1";       
}
和视图:

<div class="widget-body">

            <table class="data-table" action="./administrator/categories/delete/"><!-- Table Conversion: See Section E in custom.js -->
                <thead>
                    <tr>
                        <th class="sorting no-background" rowspan="1" colspan="1" style="width: 35px;"><input type="checkbox" id="checkall" /></th>
                        <th class="sorting" rowspan="1" colspan="1" style="width: 343px;">Tittle</th>
                        <th class="sorting" rowspan="1" colspan="1" style="width: 100px;">Date</th>
                        <th class="sorting no-background" rowspan="1" colspan="1" style="width: 70px;">#</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $ctr = 0; ?>
                    <?php foreach ($events as $n): ?>
                            <tr>
                                <td><input class="checkrow" type="checkbox" value="<?php echo $n->ev_id; ?>" /></td>
                                <td class=" sorting_1"><?= $n->ev_text; ?></td>
                                <td class="center"><?= $n->ev_date; ?></td>
                                <td>
                                    <a href="<?php echo $this->page_url; ?>/edit/<?php echo $n->ev_id; ?>" class="ico-btn ico-text-edit" title="Edit"><span>Edit</span></a>
                                    <a href="<?php echo $this->page_url; ?>/delete/<?php echo $n->ev_id; ?>" itemID="<?= $n->ev_id ?>" class="ico-btn ico-text-trash opener-delete" title="Del"><span>Del</span></a>
                                </td>
                            </tr>
                    <?php endforeach ?>
                </tbody>

            </table>



            <div class="clear"></div>
        </div>
         <div class="clear"></div>
    </div>

    <div id="table-extra">
        <div id="table-action">
            <input action="./administrator/<?php echo $this->uri->segment(2)."/deleteitems" ?>" class="btn-theme table-button btn-hover-black DeleteItems" id="submit" type="button" value="Delete" />
        </div>
        <div class="paginate">
            <ul>
                <?= $this->pagination->create_links(); ?>
            </ul>
            <div class="clear"></div>
        </div>

        <div class="clear"></div>
    </div>
</div>
</div>

窃窃私语
日期
#

您不能像这样加载模型
$events=newevents\u model()在CI中,您应该这样做:

$this->load->model('Model_name');

$this->Model_name->function();
参考: