-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathView.class.php
More file actions
150 lines (137 loc) · 3.11 KB
/
View.class.php
File metadata and controls
150 lines (137 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
/**
* Sitesクラス
*
* @package [[package名]]
* @author Ryuji.M
* @copyright copyright (c) 2006 NetCommons.org
* @license [[license]]
* @access public
*/
class Sites_View {
/**
* @var DBオブジェクトを保持
*
* @access private
*/
var $_db = null;
/**
* コンストラクター
*
* @access public
*/
function Sites_View() {
$container =& DIContainerFactory::getContainer();
//DBオブジェクト取得
$this->_db =& $container->getComponent("DbObject");
}
/**
* site_idからサイト情報取得
* @return array
* @access public
*/
function &getSitesById($id)
{
$params = array(
"site_id" => $id
);
$result = $this->_db->execute("SELECT * FROM {sites} WHERE site_id=?",$params);
if($result === false) {
//エラー
$this->_db->addError();
return $result;
}
if($result[0]['url'] === "BASE_URL") {
$result[0]['url'] = BASE_URL;
}
return $result[0];
}
/**
* urldからサイト情報取得
* @return array
* @access public
*/
function &getSitesByUrl($url)
{
if($url === BASE_URL) {
//$url = "BASE_URL";
$params = array(
"self_flag" => _ON
);
$result = $this->_db->execute("SELECT * FROM {sites} WHERE self_flag=?",$params);
} else {
$params = array(
"url" => $url
);
$result = $this->_db->execute("SELECT * FROM {sites} WHERE url=?",$params);
}
if($result === false) {
//エラー
$this->_db->addError();
return $result;
}
if(isset($result[0])) {
return $result[0];
}
$result = array();
return $result;
}
/**
* 自サイト情報取得
* @return array
* @access public
*/
function &getSelfSite()
{
$params = array(
"self_flag" => _ON
);
$result = $this->_db->execute("SELECT * FROM {sites} WHERE self_flag=?",$params);
if($result === false) {
//エラー
$this->_db->addError();
return $result;
}
if($result[0]['url'] === "BASE_URL") {
$result[0]['url'] = BASE_URL;
}
return $result[0];
}
/**
* sitesの一覧を取得する
*
* @param array $where_params Whereパラメータ引数
* @param array $order_params Orderパラメータ引数
* @param int $limit
* @param int $start
* @return array サイトリスト
* @access public
*/
function &getSites($where_params=null, $order_params = array("{sites}.self_flag"=>"DESC", "{sites}.url"=>"ASC"), $limit=null, $offset=null)
{
$result = $this->_db->selectExecute("sites", $where_params, $order_params, $limit, $offset, array($this, "_getSites"));
if($result === false) {
$this->_db->addError();
return $result;
}
return $result;
}
/**
* fetch時コールバックメソッド
* @param result adodb object
* @return array configs
* @access private
*/
function _getSites(&$result)
{
$data = array();
while ($row = $result->fetchRow()) {
if($row["self_flag"] == _ON) {
$row["url"] = BASE_URL;
}
$data[] = $row;
}
return $data;
}
}
?>