MySQL查詢相信大家都不會陌生,下面將為您介紹如何使用MySQL查詢實現查詢當天發布的所有文章,希望對您學習MySQL查詢方面能有所幫助。
代碼:
- <?php
- /*
- * Author : Fanglor
- * Email : [email protected]
- * Url : www.skyleft.com
- * Date : 2009-9-22
- */
- include "config.php";
- $today_start = mktime(0,0,0,date('m'),date('d'),date('Y'));
- $today_end = mktime(0,0,0,date('m'),date('d')+1,date('Y'));
- echo $sql = "SELECT * FROM `article` WHERE `article_time` BETWEEN '{$today_start}' AND '{$today_end}'";
- $list = getAll ($sql);
- if ($list) {
- echo "<pre>";
- var_dump ($list);
- echo "</pre>";
- }
- ?>
打印結果:
- SELECT * FROM `article` WHERE `article_time` BETWEEN '1253548800' AND '1253635200'
- array(2) {
- [0]=>
- array(7) {
- ["article_id"]=>
- string(2) "30"
- ["article_title"]=>
- string(14) "11111111111111"
- ["article_count"]=>
- string(1) "0"
- ["article_type"]=>
- string(1) "1"
- ["article_tag"]=>
- string(14) "22222222222222"
- ["article_content"]=>
- string(27) "111111111111111111111111111"
- ["article_time"]=>
- string(10) "1253626081"
- }
- [1]=>
- array(7) {
- ["article_id"]=>
- string(2) "31"
- ["article_title"]=>
- string(5) "22222"
- ["article_count"]=>
- string(1) "0"
- ["article_type"]=>
- string(1) "8"
- ["article_tag"]=>
- string(14) "22222222222222"
- ["article_content"]=>
- string(27) "222222222222222222222222222"
- ["article_time"]=>
- string(10) "1253626095"
- }
- }
MySQL日期函數和時間函數
改造自discuz的MySQL查詢類
使用Limit參數實現MySQL查詢優化
深度解析MySQL查詢緩存機制
常用MySQL命令行工具介紹