Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezresponsemultiple.php
Go to the documentation of this file.
1 <?php
4 Class eZResponseMultiple
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_ResponseMultiple
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
58 default:
59 $OrderBy = "ORDER BY ID";
60 break;
61 }
62
63 // limit
64 if ( is_numeric( $LimitStart ) )
65 {
66 $LimitArray = array( "Offset" => $LimitStart );
67
68 if ( is_numeric( $LimitBy ) )
69 {
70 $LimitArray =& array_merge( $LimitArray, array( "Limit" => $LimitBy ) );
71 }
72 }
73 else
74 {
75 $LimitArray = array();
76 }
77
78 // condi��es
79 if ( $ResponseID != "" ) { $SqlCond .= " AND ResponseID = '$ResponseID'"; }
80 if ( $QuestionID != "" ) { $SqlCond .= " AND QuestionID = '$QuestionID'"; }
81
82 $SQLQuery = "SELECT
83 ID as A
84 FROM
85 eZSurvey_ResponseMultiple";
86
87 if ( $SqlCond != "" )
88 {
89 $SQLQuery .= " WHERE " . substr( $SqlCond, 4, strlen($SqlCond) );
90 }
91
92 $response_array = array();
93 $return_array = array();
94
95 $db->array_query( $response_array, $SQLQuery );
96
97 foreach ( $response_array as $responseItem )
98 {
99 $return_array[] = new eZResponseMultiple( $responseItem[ $db->fieldName( "A" ) ] );
100 }
101 return $return_array;
102 }
103
104 function store()
105 {
106 $ret = false;
107 $db =& eZDB::globalDatabase();
108 $db->begin();
109
110 if ( !isSet( $this->ID) )
111 {
112 // create
113 $db->lock( "eZSurvey_ResponseMultiple" );
114 $this->ID = $db->nextID( "eZSurvey_ResponseMultiple", "ID" );
115 $res[] = $db->query( "INSERT INTO eZSurvey_ResponseMultiple
116 (ID, ResponseID, QuestionID, ChoiceID, Other)
117 VALUES (
118 '$this->ID',
119 '$this->ResponseID',
120 '$this->QuestionID',
121 '$this->ChoiceID',
122 '$this->Other'
123 )");
124
125 $db->unlock();
126 }
127 else
128 {
129 // update
130 $db->lock( "eZSurvey_ResponseMultiple" );
131 $res[] = $db->query( "UPDATE eZSurvey_ResponseMultiple set
132 ID = '$this->ID',
133 ResponseID = '$this->ResponseID',
134 QuestionID = '$this->QuestionID',
135 ChoiceID = '$this->ChoiceID',
136 Other = '$this->Other'
137 WHERE ID = '$this->ID'");
138
139 $db->unlock();
140 }
141 eZDB::finish( $res, $db );
142 return true;
143 }
144
145 function delete()
146 {
147 $db =& eZDB::globalDatabase();
148 $db->begin();
149
150 $res[] = $db->query( "DELETE FROM eZSurvey_ResponseMultiple WHERE ID='$this->ID'" );
151
152 eZDB::finish( $res, $db );
153 }
154
155 function deleteResponse( $ResponseID, $QuestionID )
156 {
157 $db =& eZDB::globalDatabase();
158 $db->begin();
159
160 $res[] = $db->query( "DELETE FROM eZSurvey_ResponseMultiple WHERE ResponseID = '$ResponseID' AND QuestionID = '$QuestionID'" );
161
162 eZDB::finish( $res, $db );
163 }
164
165 function deleteByQuestion( $QuestionID )
166 {
167 $db =& eZDB::globalDatabase();
168 $db->begin();
169
170 $res[] = $db->query( "DELETE FROM eZSurvey_ResponseMultiple WHERE QuestionID = '$QuestionID'" );
171
172 eZDB::finish( $res, $db );
173 }
174
175 // get functions
176 function id() { return $this->ID; }
177 function responseID() { return $this->ResponseID; }
178 function questionID() { return $this->QuestionID; }
179 function choiceID() { return $this->ChoiceID; }
180 function other() { return $this->Other; }
181
182 // set functions
183 function setID( $value ) { $this->ID = $value; }
184 function setResponseID( $value ) { $this->ResponseID = $value; }
185 function setQuestionID( $value ) { $this->QuestionID = $value; }
186 function setChoiceID( $value ) { $this->ChoiceID = $value; }
187 function setOther( $value ) { $this->Other = $value; }
188
189 // internal variables
190 var $ID;
191 var $ResponseID;
192 var $QuestionID;
193 var $ChoiceID;
194 var $Other;
195 }
196
197 ?>
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: ezresponsemultiple.php:194
$ResponseID
$ResponseID
Definition: ezresponsemultiple.php:191
$QuestionID
$QuestionID
Definition: ezresponsemultiple.php:192
eZResponseMultiple
Class eZResponseMultiple
Definition: ezresponsemultiple.php:5
$ChoiceID
$ChoiceID
Definition: ezresponsemultiple.php:193
$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+.