7 * LICENSE: This source file is licensed under the terms of the GNU General Public License.
9 * @package Magic3 Framework
10 * @author 平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11 * @copyright Copyright 2006-2007 Magic3 Project.
12 * @license http://www.gnu.org/copyleft/gpl.html GPL License
13 * @version SVN: $Id: access_countDb.php 2 2007-11-03 04:59:01Z fishbone $
14 * @link http://www.magic3.org
16 require_once($gEnvManager->getDbPath() . '/baseDb.php');
18 class access_countDb extends BaseDb
21 * 同じセッションIDのレコードがあるかどうかチェック
23 * @param string $ssid セッションID
24 * @return bool true=あり、false=なし
26 function isSessionExists($ssid)
29 $this->startTransaction();
31 $queryStr = 'select * from ac_access ';
32 $queryStr .= 'where ac_ssid = ?';
33 $ret = $this->isRecordExists($queryStr, array($ssid));
34 if ($ret){ // 存在している場合は時間を更新
35 $queryStr = 'UPDATE ac_access ';
36 $queryStr .= 'SET ac_time = ? ';
37 $queryStr .= 'WHERE ac_ssid = ?';
38 $this->execStatement($queryStr, array(time(), $ssid));
40 $queryStr = 'INSERT INTO ac_access ';
41 $queryStr .= '(ac_ssid, ac_time) ';
42 $queryStr .= 'VALUES ';
43 $queryStr .= '(?, ?)';
44 $this->execStatement($queryStr, array($ssid, time()));
48 $this->endTransaction();
54 * @param string $date 年月日(yyyy-mm-dd)
57 function incrementCount($date)
60 $this->startTransaction();
62 $queryStr = 'select * from ac_count ';
63 $queryStr .= 'where co_date = ?';
64 $ret = $this->selectRecord($queryStr, array($date), $row);
65 if ($ret){ // 存在している場合はカウンタを更新
66 $count = $row['co_count'] + 1;
67 $queryStr = 'UPDATE ac_count ';
68 $queryStr .= 'SET co_count = ? ';
69 $queryStr .= 'WHERE co_date = ?';
70 $this->execStatement($queryStr, array($count, $date));
72 $queryStr = 'INSERT INTO ac_count ';
73 $queryStr .= '(co_date, co_count) ';
74 $queryStr .= 'VALUES ';
75 $queryStr .= '(?, ?)';
76 $this->execStatement($queryStr, array($date, 1));
80 $this->endTransaction();
87 * @param string $date 年月日(yyyy-mm-dd)
90 function getCount($date)
93 $queryStr = 'select sum(co_count) as count from ac_count ';
94 $queryStr .= 'where co_date <= ?';
95 $ret = $this->selectRecord($queryStr, array($date), $row);
96 if ($ret) $count = $row['count'];