Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezresponsebool.php
Go to the documentation of this file.
1 <?php
4 Class eZResponseBool
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 FROM
23 eZSurvey_ResponseBool
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->ChoiceID = $object_array[ 0 ][ "ChoiceID" ];
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_ResponseBool";
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 eZResponseBool( $responseItem[ $db->fieldName( "A" ) ] );
97 }
98 return $return_array;
99 }
100
101 function store()
102 {
103 $ret = false;
104 $db =& eZDB::globalDatabase();
105 $db->begin();
106
107 if ( !isSet( $this->ID) )
108 {
109 // create
110 $db->lock( "eZSurvey_ResponseBool" );
111 $this->ID = $db->nextID( "eZSurvey_ResponseBool", "ID" );
112 $res[] = $db->query( "INSERT INTO eZSurvey_ResponseBool
113 (ID, ResponseID, QuestionID, ChoiceID)
114 VALUES (
115 '$this->ID',
116 '$this->ResponseID',
117 '$this->QuestionID',
118 '$this->ChoiceID'
119 )");
120
121 $db->unlock();
122 }
123 else
124 {
125 // update
126 $db->lock( "eZSurvey_ResponseBool" );
127 $res[] = $db->query( "UPDATE eZSurvey_ResponseBool set
128 ID = '$this->ID',
129 ResponseID = '$this->ResponseID',
130 QuestionID = '$this->QuestionID',
131 ChoiceID = '$this->ChoiceID'
132 WHERE ID = '$this->ID'");
133
134 $db->unlock();
135 }
136 eZDB::finish( $res, $db );
137 return true;
138 }
139
140 function delete()
141 {
142 $db =& eZDB::globalDatabase();
143 $db->begin();
144
145 $res[] = $db->query( "DELETE FROM eZSurvey_ResponseBool WHERE ID='$this->ID'" );
146
147 eZDB::finish( $res, $db );
148 }
149
150 function deleteResponse( $ResponseID, $QuestionID )
151 {
152 $db =& eZDB::globalDatabase();
153 $db->begin();
154
155 $res[] = $db->query( "DELETE FROM eZSurvey_ResponseBool WHERE ResponseID = '$ResponseID' AND QuestionID = '$QuestionID'" );
156
157 eZDB::finish( $res, $db );
158 }
159
160 function deleteByQuestion( $QuestionID )
161 {
162 $db =& eZDB::globalDatabase();
163 $db->begin();
164
165 $res[] = $db->query( "DELETE FROM eZSurvey_ResponseBool WHERE QuestionID = '$QuestionID'" );
166
167 eZDB::finish( $res, $db );
168 }
169
170 // get functions
171 function ID() { return $this->ID; }
172 function ResponseID() { return $this->ResponseID; }
173 function QuestionID() { return $this->QuestionID; }
174 function ChoiceID() { return $this->ChoiceID; }
175
176 // set functions
177 function setID( $value ) { $this->ID = $value; }
178 function setResponseID( $value ) { $this->ResponseID = $value; }
179 function setQuestionID( $value ) { $this->QuestionID = $value; }
180 function setChoiceID( $value ) { $this->ChoiceID = $value; }
181
182 // internal variables
183 var $ID;
184 var $ResponseID;
185 var $QuestionID;
186 var $ChoiceID;
187 }
188
189 ?>
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
eZResponseBool
Class eZResponseBool
Definition: ezresponsebool.php:5
$ResponseID
$ResponseID
Definition: ezresponsebool.php:184
$QuestionID
$QuestionID
Definition: ezresponsebool.php:185
$ChoiceID
$ChoiceID
Definition: ezresponsebool.php:186
$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+.