Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezresponsesingle.php
Go to the documentation of this file.
1 <?php
4 Class eZResponseSingle
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 ChoiceID,
22 Other
23 FROM
24 eZSurvey_ResponseSingle
25 WHERE
26 ID = '$id'";
27
28 $db =& eZDB::globalDatabase();
29
30 $db->array_query( $object_array, $SqlQuery );
31 if ( count( $object_array ) > 1 )
32 {
33 die( "Error: More than one object with the same ID found." );
34 }
35 elseif ( count( $object_array ) == 1 )
36 {
37 $this->ID = $object_array[ 0 ][ "ID" ];
38 $this->ResponseID = $object_array[ 0 ][ "ResponseID" ];
39 $this->QuestionID = $object_array[ 0 ][ "QuestionID" ];
40 $this->ChoiceID = $object_array[ 0 ][ "ChoiceID" ];
41 $this->Other = $object_array[ 0 ][ "Other" ];
42
43 return $this;
44 }
45 }
46
47 function getAll( $OrderBy = "ID", $ResponseID = "", $QuestionID = "", $LimitStart = "None", $LimitBy = "None" )
48 {
49 $db =& eZDB::globalDatabase();
50
51 // order by
52 switch ( strtolower( $OrderBy ) )
53 {
54 case "choiceid":
55 $OrderBy = "ORDER BY ChoiceID";
56 break;
57 default:
58 $OrderBy = "ORDER BY ID";
59 break;
60 }
61
62 // limit
63 if ( is_numeric( $LimitStart ) )
64 {
65 $LimitArray = array( "Offset" => $LimitStart );
66
67 if ( is_numeric( $LimitBy ) )
68 {
69 $LimitArray =& array_merge( $LimitArray, array( "Limit" => $LimitBy ) );
70 }
71 }
72 else
73 {
74 $LimitArray = array();
75 }
76
77 // condi��es
78 if ( $ResponseID != "" ) { $SqlCond .= " AND ResponseID = '$ResponseID'"; }
79 if ( $QuestionID != "" ) { $SqlCond .= " AND QuestionID = '$QuestionID'"; }
80
81 $SQLQuery = "SELECT
82 ID as A
83 FROM
84 eZSurvey_ResponseSingle";
85
86 if ( $SqlCond != "" )
87 {
88 $SQLQuery .= " WHERE " . substr( $SqlCond, 4, strlen($SqlCond) );
89 }
90
91 $response_array = array();
92 $return_array = array();
93
94 $db->array_query( $response_array, $SQLQuery );
95
96 foreach ( $response_array as $responseItem )
97 {
98 $return_array[] = new eZResponseSingle( $responseItem[ $db->fieldName( "A" ) ] );
99 }
100 return $return_array;
101 }
102
103 function store()
104 {
105 $ret = false;
106 $db =& eZDB::globalDatabase();
107 $db->begin();
108
109 if ( !isSet( $this->ID) )
110 {
111 // create
112 $db->lock( "eZSurvey_ResponseSingle" );
113 $this->ID = $db->nextID( "eZSurvey_ResponseSingle", "ID" );
114 $res[] = $db->query( "INSERT INTO eZSurvey_ResponseSingle
115 (ID, ResponseID, QuestionID, ChoiceID, Other)
116 VALUES (
117 '$this->ID',
118 '$this->ResponseID',
119 '$this->QuestionID',
120 '$this->ChoiceID',
121 '$this->Other'
122 )");
123
124 $db->unlock();
125 }
126 else
127 {
128 // update
129 $db->lock( "eZSurvey_ResponseSingle" );
130 $res[] = $db->query( "UPDATE eZSurvey_ResponseSingle set
131 ID = '$this->ID',
132 ResponseID = '$this->ResponseID',
133 QuestionID = '$this->QuestionID',
134 ChoiceID = '$this->ChoiceID',
135 Other = '$this->Other'
136 WHERE ID = '$this->ID'");
137
138 $db->unlock();
139 }
140 eZDB::finish( $res, $db );
141 return true;
142 }
143
144 function delete()
145 {
146 $db =& eZDB::globalDatabase();
147 $db->begin();
148
149 $res[] = $db->query( "DELETE FROM eZSurvey_ResponseSingle WHERE ID='$this->ID'" );
150
151 eZDB::finish( $res, $db );
152 }
153
154 function deleteResponse( $ResponseID, $QuestionID )
155 {
156 $db =& eZDB::globalDatabase();
157 $db->begin();
158
159 $res[] = $db->query( "DELETE FROM eZSurvey_ResponseSingle WHERE ResponseID = '$ResponseID' AND QuestionID = '$QuestionID'" );
160
161 eZDB::finish( $res, $db );
162 }
163
164 function deleteByQuestion( $QuestionID )
165 {
166 $db =& eZDB::globalDatabase();
167 $db->begin();
168
169 $res[] = $db->query( "DELETE FROM eZSurvey_ResponseSingle WHERE QuestionID = '$QuestionID'" );
170
171 eZDB::finish( $res, $db );
172 }
173
174 // get functions
175 function id() { return $this->ID; }
176 function responseID() { return $this->ResponseID; }
177 function questionID() { return $this->QuestionID; }
178 function choiceID() { return $this->ChoiceID; }
179 function other() { return $this->Other; }
180
181 // set functions
182 function setID( $value ) { $this->ID = $value; }
183 function setResponseID( $value ) { $this->ResponseID = $value; }
184 function setQuestionID( $value ) { $this->QuestionID = $value; }
185 function setChoiceID( $value ) { $this->ChoiceID = $value; }
186 function setOther( $value ) { $this->Other = $value; }
187
188 // internal variables
189 var $ID;
190 var $ResponseID;
191 var $QuestionID;
192 var $ChoiceID;
193 var $Other;
194 }
195
196 ?>
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$Other
$Other
Definition: ezresponsesingle.php:193
eZResponseSingle
Class eZResponseSingle
Definition: ezresponsesingle.php:5
$ResponseID
$ResponseID
Definition: ezresponsesingle.php:190
$QuestionID
$QuestionID
Definition: ezresponsesingle.php:191
$ChoiceID
$ChoiceID
Definition: ezresponsesingle.php:192
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$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+.