讯睿CMS问答:求一个数组入数据库的例子;参考了这个但是一直报有错误(小白)

讯睿CMS问答:求一个数组入数据库的例子;参考了这个但是一直报有错误(小白)

2024-04-17 XunRuiCMS Sincere

问题:

求一个数组insert入数据库的例子;

$field = $this->get_cache('module-'.SITE_ID.'-'.APP_DIR, 'field');

foreach ($field as $t) {

$name = $t['fieldname'];

if ($name && isset($data[$name])) $add[$t['ismain']][$name] = $data[$name];

}

参考了这个 但是一直报 $this 有错误(PHP小白)

答案:

https://codeigniter.org.cn/user_guide/database/query_builder.html#id8

回复@黄卿

Using $this when not in object context

直接这样写的话会报错

看在

一楼手册可以insert

迅睿框架创始人:谢谢,学习了。