What do post get_results in ci framework each return?
世界只因有你
世界只因有你 2017-07-05 09:44:32
0
3
990

Modify a system online and offline. Novices cannot understand this ci framework. . . I don't know how to change it to achieve my function.

public function getImagesById88() {
        $v  = array(); 
        $id = intval($this->input->post('id',TRUE));
        $list = $this->mysql_model->get_results(contract_IMG,'(invId='.$id.') and isDelete=0');
        foreach ($list as $arr=>$row) {
            $v[$arr]['pid']          = $row['id'];
            $v[$arr]['status']       = 1;
            $v[$arr]['name']         = $row['name'];
            $v[$arr]['url']          = site_url().'/basedata/inventory/getImage88?action=getImage88&pid='.$row['id'];
            $v[$arr]['thumbnailUrl'] = site_url().'/basedata/inventory/getImage88?action=getImage88&pid='.$row['id'];
            $v[$arr]['deleteUrl']    = '';
            $v[$arr]['deleteType']   = '';
        }
        $data['status'] = 200;
        $data['msg']    = 'success';
        $data['files']  = $v;
        die(json_encode($data));  
    }
``
JS代码:
initDom: function() {
            var b = a.api.data || {};
            b.id && Public.ajaxPost("../basedata/inventory/getImagesById88", {
                id: b.id
            }, function(b) {
                200 == b.status ? a.addImgp(b.files) : parent.parent.Public.tips({
                    type: 1,
                    content: "获取商品图片失败!"
                })
            })
        },

我改的是传入的id值,本来只是数字,后来需要改成带有字母的,intval就变成0了。
感激不尽!


世界只因有你
世界只因有你

reply all(3)
学习ing

If you want to change the id to a non-number, remove the intval, and then add single quotes to the variable $id in the sql in the second parameter of get_results

public function getImagesById88() {
        $v  = array(); 
        $id = $this->input->post('id',TRUE);
        $list = $this->mysql_model->get_results(contract_IMG,'(invId=\''.$id.'\') and isDelete=0');
        foreach ($list as $arr=>$row) {
            $v[$arr]['pid']          = $row['id'];
            $v[$arr]['status']       = 1;
            $v[$arr]['name']         = $row['name'];
            $v[$arr]['url']          = site_url().'/basedata/inventory/getImage88?action=getImage88&pid='.$row['id'];
            $v[$arr]['thumbnailUrl'] = site_url().'/basedata/inventory/getImage88?action=getImage88&pid='.$row['id'];
            $v[$arr]['deleteUrl']    = '';
            $v[$arr]['deleteType']   = '';
        }
        $data['status'] = 200;
        $data['msg']    = 'success';
        $data['files']  = $v;
        die(json_encode($data));  
    }
巴扎黑

intval is a variable converted to an integer type. The default is decimal. If your ID has changed to a letter, it is not suitable to use this

黄舟

Please read the CI manual first, it explains it very clearly.
get_results should be encapsulated by itself. I have never seen this framework method.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template