THINKPHP sql查询的问题

WBOY
Release: 2016-06-23 13:56:55
Original
849 people have browsed it

比如一个表,如果要查询单个字段所有的值怎么写呢,我就知道如果查全部的就是

$m=M('Table');$result=$m->select();$this->assign('res',$result);
Copy after login

//然后前台用volist来循环出 $res的值。

那如果我只是要查询 table下的 name 字段的所有值怎么写呢,手册上面也没有,搜了下没啥发现。


另外还有一个问题就是如果用统计查询结果怎么赋值给前台显示呢,比如 用 $m->count(); 得到这个表的个数,用dump打印出来就一个值,不知道怎么用什么在前台显示出来。


回复讨论(解决方案)

$m=M('Table');$result=$m->field('name')->select();$this->assign('res',$result);
Copy after login
Copy after login

$m=M('Table');$result=$m->field('name')->select();$this->assign('res',$result);
Copy after login
Copy after login



原来如此,我现在也在弄ThinkPHP

手册上面也没有,搜了下没啥发现。

那你是没有仔细看吧
http://doc.thinkphp.cn/manual/query.html

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!