Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezformelementfixedvalue.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezformelementfixedvalue.php 7715 2001-10-09 09:04:27Z ce $
5 //
6 // ezformelementtype class
7 //
8 // Created on: <11-Jun-2001 12:07:57 pkej>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
31
39 // include_once( "ezform/classes/ezform.php" );
40
41 class eZFormElementFixedValue
42 {
43
50 function __construct( $id=-1 )
51 {
52 if ( is_array( $id ) )
53 {
54 $this->fill( $id );
55 }
56 else if ( $id != -1 )
57 {
58 $this->ID = $id;
59 $this->get( $this->ID );
60 }
61 }
62
66 function store()
67 {
68 $db =& eZDB::globalDatabase();
69 $db->begin();
70
71 $value =& $db->escapeString( $this->Value );
72
73 if ( empty( $this->ID ) )
74 {
75 $db->lock( "eZForm_FormElementFixedValues" );
76 $nextID = $db->nextID( "eZForm_FormElementFixedValues", "ID" );
77 $res[] = $db->query( "INSERT INTO eZForm_FormElementFixedValues
78 ( ID, Value )
79 VALUES
80 ( '$nextID', '$value' )" );
81
82 $this->ID = $nextID;
83 }
84 elseif ( is_numeric( $this->ID ) )
85 {
86 $res[] = $db->query( "UPDATE eZForm_FormElementFixedValues SET Value='$value' WHERE ID='$this->ID'" );
87 }
88 eZDB::finish( $res, $db );
89 return true;
90 }
91
95 function delete( $formID=-1 )
96 {
97 if ( $formID == -1 )
98 $formID = $this->ID;
99
100 $db =& eZDB::globalDatabase();
101 $db->begin();
102
103
104 $res[] = $db->query( "DELETE FROM eZForm_FormElementFixedValueLink WHERE FixedValueID=$formID" );
105 $res[] = $db->query( "DELETE FROM eZForm_FormElementFixedValues WHERE ID=$formID" );
106 eZDB::finish( $res, $db );
107
108 }
109
115 function get( $id=-1 )
116 {
117 $db =& eZDB::globalDatabase();
118
119 $ret = false;
120 if ( $id != "-1" )
121 {
122 $db->array_query( $formArray, "SELECT * FROM eZForm_FormElementFixedValues WHERE ID='$id'",
123 0, 1 );
124
125 if( count( $formArray ) == 1 )
126 {
127 $this->fill( $formArray[0] );
128 $ret = true;
129 }
130 elseif( count( $formArray ) != 1 )
131 {
132 $this->ID = 0;
133 }
134 }
135 return $ret;
136 }
137
141 function fill( &$formArray )
142 {
143 $db =& eZDB::globalDatabase();
144 $this->ID = $formArray["ID"];
145 $this->Value = $formArray["Value"];
146 }
147
153 function &getAll( )
154 {
155 $db =& eZDB::globalDatabase();
156
157 $returnArray = array();
158 $formArray = array();
159
160 $db->array_query( $formArray, "SELECT ID
161 FROM eZForm_FormElementFixedValues
162 ORDER BY Value DESC
163 " );
164
165 for ( $i=0; $i < count($formArray); $i++ )
166 {
167 $returnArray[$i] = new eZFormElementFixedValue( $formArray[$i][$db->fieldValue( "ID" )] );
168 }
169
170 return $returnArray;
171 }
172
176 function count()
177 {
178 $db =& eZDB::globalDatabase();
179 $ret = false;
180
181 $db->query_single( $result, "SELECT COUNT(ID) as Count
182 FROM eZForm_FormElementFixedValues" );
183 $ret = $result[$db->fieldValue( "Count" )];
184 return $ret;
185 }
186
190 function id()
191 {
192 return $this->ID;
193 }
194
198 function &value()
199 {
200 return htmlspecialchars( $this->Value );
201 }
202
206 function setValue( &$value )
207 {
208 $this->Value = $value;
209 }
210 var $ID;
211 var $Value;
212 }
213
214 ?>
$i
$i
Definition: admin/adlist.php:91
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZFormElementFixedValue
Definition: ezformelementfixedvalue.php:42
eZFormElementFixedValue\getAll
& getAll()
Definition: ezformelementfixedvalue.php:153
eZFormElementFixedValue\value
& value()
Definition: ezformelementfixedvalue.php:198
eZFormElementFixedValue\setValue
setValue(&$value)
Definition: ezformelementfixedvalue.php:206
eZFormElementFixedValue\id
id()
Definition: ezformelementfixedvalue.php:190
eZFormElementFixedValue\__construct
__construct( $id=-1)
Definition: ezformelementfixedvalue.php:50
eZFormElementFixedValue\$ID
$ID
Definition: ezformelementfixedvalue.php:210
eZFormElementFixedValue\count
count()
Definition: ezformelementfixedvalue.php:176
eZFormElementFixedValue\store
store()
Definition: ezformelementfixedvalue.php:66
eZFormElementFixedValue\$Value
$Value
Definition: ezformelementfixedvalue.php:211
eZFormElementFixedValue\fill
fill(&$formArray)
Definition: ezformelementfixedvalue.php:141
$result
$result
Definition: companysearch.php:94
$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
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.