Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

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