Was geben get_results im CI-Framework jeweils zurück?
世界只因有你
世界只因有你 2017-07-05 09:44:32
0
3
868

Ändern Sie ein System online und offline. Anfänger können dieses CI-Framework nicht verstehen. . . Ich weiß nicht, wie ich es ändern soll, um meine Funktion zu erreichen.

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了。
感激不尽!


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

Antworte allen(3)
学习ing

你如果要把id变成非数字的话,把intval去掉,然后要把get_results第二个参数中的sql中的变量$id要加上单引号

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是变量转成整数类型 默认按照十进制 你的id都变成带字母的就不适合用这个了

黄舟

CI的手册,先看一遍吧,里面讲的很清楚。
get_results这个应该是自己封装的,没见过这个框架方法。

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage