Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezpollchoice.php
Go to the documentation of this file.
1 <?php
3 // $Id: ezpollchoice.php 8236 2001-11-01 21:32:06Z bf $
4 //
5 // Definition of eZPollChoice class
6 //
7 // Created on: <19-Sep-2000 17:37:53 ce>
8 //
9 // This source file is part of Exponential Basic, publishing software.
10 //
11 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
12 //
13 // This program is free software; you can redistribute it and/or
14 // modify it under the terms of the GNU General Public License
15 // as published by the Free Software Foundation; either version 2
16 // of the License, or (at your option) any later version.
17 //
18 // This program is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
26 //
27
30
42 // include_once( "classes/ezdb.php" );
43
44 class eZPollChoice
45 {
50 function __construct( $id=-1 )
51 {
52 $this->Offset = 0;
53
54 if ( $id != -1 )
55 {
56 $this->ID = $id;
57 $this->get( $this->ID );
58 }
59 }
60
64 function store()
65 {
66 $db =& eZDB::globalDatabase();
67
68 $db->begin();
69
70 $name = $db->escapeString( $this->Name );
71
72 if ( !isset ( $this->ID ) )
73 {
74 $db->lock( "eZPoll_PollChoice" );
75 $nextID = $db->nextID( "eZPoll_PollChoice", "ID" );
76
77 $res = $db->query( "INSERT INTO eZPoll_PollChoice
78 ( ID, Name, PollID, Offs ) VALUES
79 ( '$nextID',
80 '$name',
81 '$this->PollID',
82 '$this->Offset' ) ");
83
84 $this->ID = $nextID;
85 }
86 else
87 {
88 $res = $db->query( "UPDATE eZPoll_PollChoice SET
89 Name='$name',
90 Offs='$this->Offset' WHERE ID='$this->ID'" );
91 }
92
93 $db->unlock();
94
95 if ( $res == false )
96 $db->rollback( );
97 else
98 $db->commit();
99
100 return true;
101 }
102
106 function delete()
107 {
108 $db =& eZDB::globalDatabase();
109
110 if ( isset ( $this->ID ) )
111 {
112 $db->query( "DELETE FROM eZPoll_Vote WHERE ChoiceID='$this->ID'" );
113 $db->query( "DELETE FROM eZPoll_PollChoice WHERE ID='$this->ID'" );
114 }
115 return true;
116 }
117
118
122 function get( $id=-1 )
123 {
124 $db =& eZDB::globalDatabase();
125 $ret = false;
126
127 if ( $id != -1 )
128 {
129 $db->array_query( $poll_array, "SELECT * FROM eZPoll_PollChoice WHERE ID='$id' ORDER By ID" );
130
131 if ( count( $poll_array ) > 1 )
132 {
133 die( "Error: Poll's wit the same ID was found in the database." );
134 }
135 else if ( count( $poll_array ) == 1 )
136 {
137 $this->ID = $poll_array[0][$db->fieldName("ID")];
138 $this->Name = $poll_array[0][$db->fieldName("Name")];
139 $this->PollID = $poll_array[0][$db->fieldName("PollID")];
140 $this->Offset = $poll_array[0][$db->fieldName("Offs")];
141
142 $ret = true;
143 }
144 }
145
146 return $ret;
147 }
148
152 function getAll( $ID )
153 {
154 $db =& eZDB::globalDatabase();
155
156 $return_array = array();
157 $poll_array = array();
158
159 $db->array_query( $poll_array, "SELECT ID FROM eZPoll_PollChoice WHERE PollID='$ID' ORDER By ID" );
160
161 for ( $i=0; $i<count( $poll_array ); $i++ )
162 {
163 $return_array[$i] = new eZPollChoice( $poll_array[$i][$db->fieldName("ID")], 0 );
164 }
165
166 return $return_array;
167 }
168
172 function name( $html = true )
173 {
174 if( $html && !is_null( $this->Name ) )
175 return htmlspecialchars( $this->Name );
176 else
177 return $this->Name;
178 }
179
183 function id()
184 {
185 return $this->ID;
186 }
187
188
192 function offset()
193 {
194 return $this->Offset;
195 }
196
197
201 function pollID()
202 {
203 return $this->PollID;
204 }
205
209 function setName( $value )
210 {
211 $this->Name = $value;
212 }
213
217 function setOffset( $value )
218 {
219 $this->Offset = $value;
220 }
221
225 function setPollID( $value )
226 {
227 $this->PollID = $value;
228 }
229
233 function voteCount( )
234 {
235 $db =& eZDB::globalDatabase();
236 $db->array_query( $votecount, "SELECT COUNT(*) AS NUMBER FROM eZPoll_Vote WHERE ChoiceID='$this->ID'" );
237
238 return (int)$votecount[0][$db->fieldName("NUMBER")];
239 }
240
241 var $ID;
242 var $Name;
243 var $PollID;
244 var $Offset;
245 }
246
247 ?>
$i
$i
Definition: admin/adlist.php:91
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZPollChoice
Definition: ezpollchoice.php:45
eZPollChoice\$ID
$ID
Definition: ezpollchoice.php:241
eZPollChoice\setName
setName( $value)
Definition: ezpollchoice.php:209
eZPollChoice\$Name
$Name
Definition: ezpollchoice.php:242
eZPollChoice\offset
offset()
Definition: ezpollchoice.php:192
eZPollChoice\$Offset
$Offset
Definition: ezpollchoice.php:244
eZPollChoice\store
store()
Definition: ezpollchoice.php:64
eZPollChoice\__construct
__construct( $id=-1)
Definition: ezpollchoice.php:50
eZPollChoice\$PollID
$PollID
Definition: ezpollchoice.php:243
eZPollChoice\voteCount
voteCount()
Definition: ezpollchoice.php:233
eZPollChoice\name
name( $html=true)
Definition: ezpollchoice.php:172
eZPollChoice\getAll
getAll( $ID)
Definition: ezpollchoice.php:152
eZPollChoice\setOffset
setOffset( $value)
Definition: ezpollchoice.php:217
eZPollChoice\setPollID
setPollID( $value)
Definition: ezpollchoice.php:225
eZPollChoice\pollID
pollID()
Definition: ezpollchoice.php:201
eZPollChoice\id
id()
Definition: ezpollchoice.php:183
$name
$name
Definition: companytypelist.php:194
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
Name
if($user) if(isset( $next) && $next)<?=isset($all_fields_error) &&$all_fields_error ?><?=isset($password_error) &&$password_error ?></p ><? endif;?>< form method="post">< table border="0" cellspacing="2" cellpadding="2" class="boxtext" style="font-size=13;">< tr >< td style="color:<?= isset( $error['first_name'] ) ?> First Name
Definition: step1.php:127
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.