OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / widgets / top_content_box / include / db / top_content_boxDb.php
1 <?php
2 /**
3  * DBクラス
4  *
5  * PHP versions 5
6  *
7  * LICENSE: This source file is licensed under the terms of the GNU General Public License.
8  *
9  * @package    Magic3 Framework
10  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11  * @copyright  Copyright 2006-2008 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: top_content_boxDb.php 2446 2009-10-22 05:00:48Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 require_once($gEnvManager->getDbPath() . '/baseDb.php');
17
18 class top_content_boxDb extends BaseDb
19 {
20         /**
21          * 閲覧数が多い順にコンテンツリストを取得
22          *
23          * @param string   $typeId              コンテンツタイプ
24          * @param bool     $all                 すべてのデータを取得するか、ユーザ制限のないデータを取得するかを指定
25          * @param string        $now                            現在日時
26          * @param function $callback    コールバック関数
27          * @return                                              なし
28          */
29         function getContentList($typeId, $all, $now, $callback)
30         {
31                 $initDt = $this->gEnv->getInitValueOfTimestamp();
32                 $params = array();
33                 
34                 $queryStr  = 'SELECT vc_content_serial,SUM(vc_count) AS total,cn_id,cn_name,cn_deleted,cn_visible FROM _view_count LEFT JOIN content ON vc_content_serial = cn_serial ';
35                 $queryStr .=   'WHERE vc_type_id = ? '; $params[] = $typeId;
36                 $queryStr .=     'AND cn_deleted = false ';
37                 $queryStr .=     'AND cn_visible = true ';
38                 if (!$all) $queryStr .=    'AND cn_user_limited = false ';              // ユーザ制限のないデータ
39                 
40                 // 公開期間を指定
41                 $queryStr .=    'AND (cn_active_start_dt = ? OR (cn_active_start_dt != ? AND cn_active_start_dt <= ?)) ';
42                 $queryStr .=    'AND (cn_active_end_dt = ? OR (cn_active_end_dt != ? AND cn_active_end_dt > ?)) ';
43                 $params[] = $initDt;
44                 $params[] = $initDt;
45                 $params[] = $now;
46                 $params[] = $initDt;
47                 $params[] = $initDt;
48                 $params[] = $now;
49                 
50                 $queryStr .=   'GROUP BY vc_content_serial ';
51                 $queryStr .=   'ORDER BY total DESC';
52                 $this->selectLoop($queryStr, $params, $callback);
53         }
54 }
55 ?>