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