ThinPHP中Join实用举例

这里 使用 了 两个 表, 第 一个 表 为 Bericht 表, 第二 个 表 为 Categorie 表.

MYSQL 语句 为:

 SELECT count (*) AS total_num, a.cate_id, b.name FROM na een LEFT JOIN categorie b ON a.cate_id = b.id WHERE a.status = 'a' GROUP BY a.cate_id ORDER BY b.name

ThinkPHP 中 的 写法 Join:

 $ Blog = D ("Post");
 $ Blog-> tabel ('post a') -> join ("categorie b ON a.cate_id = b.id") -> veld ('count (*) AS total_num, a.cate_id, t.name') - > group ("a.cate_id") -> order ("b.name ') -> waar (" a.status =' a '") -> findall Hiermee kunt ();

Deel dit bericht:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Heerlijk BlinkList Furl

No Responses to "ThinPHP 中 Join 实用 举例"

Laat een reactie achter:

Naam (verplicht):
Mail (zal niet worden gepubliceerd) (verplicht):
Website:
Reactie (verplicht):
XHTML: Je kan deze tags gebruiken: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>