Home > Backend Development > PHP Tutorial > mysql - Thinkphp 的连贯查询语句正确表达

mysql - Thinkphp 的连贯查询语句正确表达

WBOY
Release: 2016-06-06 20:19:16
Original
1416 people have browsed it

有一条查询语句用连贯查询
用原生的sqlo语句是

<code>select tuser,count(*) as t1 from chat_members  GROUP BY tuser  DES</code>
Copy after login
Copy after login

查询出来的结果是

<code>array (size=2)
  0 => 
    array (size=2)
      'tuser' => string 'system' (length=6)
      't1' => string '2' (length=1)
  1 => 
    array (size=2)
      'tuser' => string 'admin' (length=5)
      't1' => string '1' (length=1)</code>
Copy after login
Copy after login

但是如果用thinkphp的连贯查询就不知道怎么写了,我现在查询语句是这样的

<code>M('members')->field(array('tuser'=>'t1'))->group('tuser desc')->select();</code>
Copy after login
Copy after login

当然这样明显是错的,不知道有没有大神来纠正一下.有没有好的方法.
小弟在此谢过了.

回复内容:

有一条查询语句用连贯查询
用原生的sqlo语句是

<code>select tuser,count(*) as t1 from chat_members  GROUP BY tuser  DES</code>
Copy after login
Copy after login

查询出来的结果是

<code>array (size=2)
  0 => 
    array (size=2)
      'tuser' => string 'system' (length=6)
      't1' => string '2' (length=1)
  1 => 
    array (size=2)
      'tuser' => string 'admin' (length=5)
      't1' => string '1' (length=1)</code>
Copy after login
Copy after login

但是如果用thinkphp的连贯查询就不知道怎么写了,我现在查询语句是这样的

<code>M('members')->field(array('tuser'=>'t1'))->group('tuser desc')->select();</code>
Copy after login
Copy after login

当然这样明显是错的,不知道有没有大神来纠正一下.有没有好的方法.
小弟在此谢过了.

<code>M('members')->field('tuser,count(*) as t1')->group('tuser')->select();


后面是order by吗,group by不会接desc</code>
Copy after login
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