如果查询出来的note字段的值是一个JSON字符串,可以使用json_decode函数将其转换成对象或数组。修改后的代码如下:

$results = $DB->select('goods', ['gid', 'money', 'name', 'note'], ['name[~]' => $name, 'LIMIT' => [$offset, $limit]]);

foreach ($results as &$result) { $result['note'] = json_decode($result['note'], true); }

注意,在json_decode函数中加上true参数,将返回一个数组而非对象。这样就可以直接访问note字段中的属性了。

$result = $DB-selectgoods gid money name note name~ = $name LIMIT = $offset $limit;php把数据库查出的这个字符串note例如cid1882yid1变对象怎么写查询出来的是一个商品列表每条记录都有note字段$results = $DB-selectgoods gid money name note name~ =

原文地址: https://www.cveoy.top/t/topic/bdyv 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录