Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezresponsedate.php
Go to the documentation of this file.
1 <?php
4 class eZResponseDate
5 {
6 function __construct( $id = "-1" )
7 {
8 if ( $id != -1 )
9 {
10 $this->ID = $id;
11 $this->get( $this->ID );
12 }
13 }
14
15 function get( $id = "-1" )
16 {
17 $SqlQuery = "SELECT
18 ID,
19 ResponseID,
20 QuestionID,
21 Response
22 FROM
23 eZSurvey_ResponseDate
24 WHERE
25 ID = '$id'";
26
27 $db =& eZDB::globalDatabase();
28
29 $db->array_query( $object_array, $SqlQuery );
30 if ( count( $object_array ) > 1 )
31 {
32 die( "Error: More than one object with the same ID found." );
33 }
34 elseif ( count( $object_array ) == 1 )
35 {
36 $this->ID = $object_array[ 0 ][ "ID" ];
37 $this->ResponseID = $object_array[ 0 ][ "ResponseID" ];
38 $this->QuestionID = $object_array[ 0 ][ "QuestionID" ];
39 $this->Response = $object_array[ 0 ][ "Response" ];
40
41 return $this;
42 }
43 }
44
45 function getAll( $OrderBy = "ID", $ResponseID = "", $QuestionID = "", $LimitStart = "None", $LimitBy = "None" )
46 {
47 $db =& eZDB::globalDatabase();
48
49 // order by
50 switch ( strtolower( $OrderBy ) )
51 {
52 case "choiceid":
53 $OrderBy = "ORDER BY ChoiceID";
54 break;
55 default:
56 $OrderBy = "ORDER BY ID";
57 break;
58 }
59
60 // limit
61 if ( is_numeric( $LimitStart ) )
62 {
63 $LimitArray = array( "Offset" => $LimitStart );
64
65 if ( is_numeric( $LimitBy ) )
66 {
67 $LimitArray =& array_merge( $LimitArray, array( "Limit" => $LimitBy ) );
68 }
69 }
70 else
71 {
72 $LimitArray = array();
73 }
74
75 // condi��es
76 if ( $ResponseID != "" ) { $SqlCond .= " AND ResponseID = '$ResponseID'"; }
77 if ( $QuestionID != "" ) { $SqlCond .= " AND QuestionID = '$QuestionID'"; }
78
79 $SQLQuery = "SELECT
80 ID as A
81 FROM
82 eZSurvey_ResponseDate";
83
84 if ( $SqlCond != "" )
85 {
86 $SQLQuery .= " WHERE " . substr( $SqlCond, 4, strlen($SqlCond) );
87 }
88
89 $response_array = array();
90 $return_array = array();
91
92 $db->array_query( $response_array, $SQLQuery );
93
94 foreach ( $response_array as $responseItem )
95 {
96 $return_array[] = new eZResponseDate( $responseItem[ $db->fieldName( "A" ) ] );
97 }
98 return $return_array;
99 }
100
101 function makeTimestamp( $date )
102 {
103 if ( $date != "" )
104 {
105 $data_array = explode( "-", $date );
106 if ( count($data_array) == 3 )
107 {
108 $timestamp = mktime( 0, 0, 0, $data_array[1], $data_array[0], $data_array[2] );
109 }
110 }
111 else
112 {
113 $timestamp = "null";
114 }
115
116 return $timestamp;
117 }
118
119 function makeDate( $timestamp )
120 {
121 if ( $timestamp != "" )
122 {
123 $date = date( "d-m-Y", $timestamp );
124 }
125
126 return $date;
127 }
128
129 function store()
130 {
131 $ret = false;
132 $db =& eZDB::globalDatabase();
133 $db->begin();
134
135 if ( !isSet( $this->ID) )
136 {
137 // create
138 $db->lock( "eZSurvey_ResponseDate" );
139 $this->ID = $db->nextID( "eZSurvey_ResponseDate", "ID" );
140 $res[] = $db->query( "INSERT INTO eZSurvey_ResponseDate
141 (ID, ResponseID, QuestionID, Response)
142 VALUES (
143 '$this->ID',
144 '$this->ResponseID',
145 '$this->QuestionID',
146 '" . $this->Response . "'
147 )");
148
149 $db->unlock();
150 }
151 else
152 {
153 // update
154 $db->lock( "eZSurvey_ResponseDate" );
155 $res[] = $db->query( "UPDATE eZSurvey_ResponseDate set
156 ID = '$this->ID',
157 ResponseID = '$this->ResponseID',
158 QuestionID = '$this->QuestionID',
159 Response = '" . $this->Response . "'
160 WHERE ID = '$this->ID'");
161
162 $db->unlock();
163 }
164 eZDB::finish( $res, $db );
165 return true;
166 }
167
168 function delete()
169 {
170 $db =& eZDB::globalDatabase();
171 $db->begin();
172
173 $res[] = $db->query( "DELETE FROM eZSurvey_ResponseDate WHERE ID='$this->ID'" );
174
175 eZDB::finish( $res, $db );
176 }
177
178 function deleteResponse( $ResponseID, $QuestionID )
179 {
180 $db =& eZDB::globalDatabase();
181 $db->begin();
182
183 $res[] = $db->query( "DELETE FROM eZSurvey_ResponseDate WHERE ResponseID = '$ResponseID' AND QuestionID = '$QuestionID'" );
184
185 eZDB::finish( $res, $db );
186 }
187
188 function deleteByQuestion( $QuestionID )
189 {
190 $db =& eZDB::globalDatabase();
191 $db->begin();
192
193 $res[] = $db->query( "DELETE FROM eZSurvey_ResponseDate WHERE QuestionID = '$QuestionID'" );
194
195 eZDB::finish( $res, $db );
196 }
197
198 // get functions
199 function id() { return $this->ID; }
200 function responseID() { return $this->ResponseID; }
201 function questionID() { return $this->QuestionID; }
202 function response() { return $this->Response; }
203
204 // set functions
205 function setID( $value ) { $this->ID = $value; }
206 function setResponseID( $value ) { $this->ResponseID = $value; }
207 function setQuestionID( $value ) { $this->QuestionID = $value; }
208 function setResponse( $value ) { $this->Response = $value; }
209
210 // internal variables
211 var $ID;
212 var $ResponseID;
213 var $QuestionID;
214 var $Response;
215 }
216
217 ?>
$date
$date
Definition: bugpreview.php:66
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZResponseDate
Definition: ezresponsedate.php:5
eZResponseDate\store
store()
Definition: ezresponsedate.php:129
eZResponseDate\setQuestionID
setQuestionID( $value)
Definition: ezresponsedate.php:207
eZResponseDate\response
response()
Definition: ezresponsedate.php:202
eZResponseDate\makeTimestamp
makeTimestamp( $date)
Definition: ezresponsedate.php:101
eZResponseDate\responseID
responseID()
Definition: ezresponsedate.php:200
eZResponseDate\$QuestionID
$QuestionID
Definition: ezresponsedate.php:213
eZResponseDate\setResponse
setResponse( $value)
Definition: ezresponsedate.php:208
eZResponseDate\setResponseID
setResponseID( $value)
Definition: ezresponsedate.php:206
eZResponseDate\$ResponseID
$ResponseID
Definition: ezresponsedate.php:212
eZResponseDate\$Response
$Response
Definition: ezresponsedate.php:214
eZResponseDate\__construct
__construct( $id="-1")
Definition: ezresponsedate.php:6
eZResponseDate\questionID
questionID()
Definition: ezresponsedate.php:201
eZResponseDate\id
id()
Definition: ezresponsedate.php:199
eZResponseDate\deleteByQuestion
deleteByQuestion( $QuestionID)
Definition: ezresponsedate.php:188
eZResponseDate\deleteResponse
deleteResponse( $ResponseID, $QuestionID)
Definition: ezresponsedate.php:178
eZResponseDate\$ID
$ID
Definition: ezresponsedate.php:211
eZResponseDate\getAll
getAll( $OrderBy="ID", $ResponseID="", $QuestionID="", $LimitStart="None", $LimitBy="None")
Definition: ezresponsedate.php:45
eZResponseDate\makeDate
makeDate( $timestamp)
Definition: ezresponsedate.php:119
eZResponseDate\setID
setID( $value)
Definition: ezresponsedate.php:205
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$timestamp
$timestamp
Definition: ezstats/admin/cron.php:35
$res
$res
Definition: ezstats/admin/cron.php:45
$OrderBy
$OrderBy
Definition: reciverpopup.php:21
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.