Home  >  Article  >  Backend Development  >  THINKPHP sql查询的有关问题

THINKPHP sql查询的有关问题

WBOY
WBOYOriginal
2016-06-13 11:57:36683browse

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

$m=M('Table');<br />$result=$m->select();<br />$this->assign('res',$result);

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

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


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

引用:
<br />$m=M('Table');<br />$result=$m->field('name')->select();<br />$this->assign('res',$result);<br /><br />


原来如此,我现在也在弄ThinkPHP
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