Home >Backend Development >PHP Tutorial >discuz中如何写操作数据库的句子

discuz中如何写操作数据库的句子

WBOY
WBOYOriginal
2016-06-23 13:48:42964browse

比如我想取portal_category这个表中所有字段的值
C::t('portal_category')->fetch........................ 后面怎么写呢?


回复讨论(解决方案)

C::t('portal_category')->fetch($id);//$id是主键
你可以到/source/class/table/目录下查看所有封装的表模型
你也可以用DB类操作数据库(表模型底层都是用的DB类操作的)
$res=DB::fetch_first('select * from %t where catid=%d',array('portal_category',1));

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn