Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezproductpricerange.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezproductpricerange.php 7848 2001-10-15 11:32:18Z ce $
5 //
6 // eZProductPricerange class
7 //
8 // Christoffer A. Elo <ce@ez.no>
9 // Created on: <07-Sep-2001 12:38:17 ce>
10 //
11 // This source file is part of Exponential Basic, publishing software.
12 // Copyright (C) 1999-2001 eZ systems as
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
44 // include_once( "classes/ezdate.php" );
45 // include_once( "eztrade/classes/ezorder.php" );
46
47 class eZProductPriceRange
48 {
49
56 function __construct( $id=-1 )
57 {
58 if ( is_array( $id ) )
59 {
60 $this->fill( $id );
61 }
62 else if ( $id != -1 )
63 {
64 $this->ID = $id;
65 $this->get( $this->ID );
66 }
67 }
68
72 function store()
73 {
74 $db =& eZDB::globalDatabase();
75 $db->begin();
76
77 if ( !isset( $this->ID ) )
78 {
79 $db->lock( "eZTrade_ProductPriceRange" );
80 $nextID = $db->nextID( "eZTrade_ProductPriceRange", "ID" );
81 $timeStamp =& (new eZDateTime())->timeStamp( true );
82 $password = md5( $this->Password );
83
84 $res = $db->query( "INSERT INTO eZTrade_ProductPriceRange
85 ( ID, Max, Min, ProductID )
86 VALUES
87 ( '$nextID',
88 '$this->Max',
89 '$this->Min',
90 '$this->ProductID'
91 )" );
92
93 $this->ID = $nextID;
94 }
95 elseif ( is_numeric( $this->ID ) )
96 {
97 $res = $db->query( "UPDATE eZTrade_ProductPriceRange SET
98 Min='$this->Min',
99 Max='$this->Max',
100 ProductID='$this->ProductID'
101 WHERE ID='$this->ID'" );
102 }
103 $db->unlock();
104
105 if ( $res == false )
106 $db->rollback( );
107 else
108 $db->commit();
109
110 return true;
111 }
112
116 function delete( $catID=-1 )
117 {
118 if ( $catID == -1 )
119 $catID = $this->ID;
120
121 $db =& eZDB::globalDatabase();
122 $db->begin();
123
124 $res = $db->query( "DELETE FROM eZTrade_ProductPriceRange WHERE ID='$this->ID'" );
125
126 if ( $ret == false )
127 $db->rollback( );
128 else
129 $db->commit();
130 }
131
137 function get( $id=-1 )
138 {
139 $db =& eZDB::globalDatabase();
140
141 $ret = false;
142 if ( $id != "" )
143 {
144 $db->array_query( $productArray, "SELECT * FROM eZTrade_ProductPriceRange WHERE ID='$id'",
145 0, 1 );
146 if( count( $productArray ) == 1 )
147 {
148 $this->fill( $productArray[0] );
149 $ret = true;
150 }
151 elseif( count( $productArray ) == 1 )
152 {
153 $this->ID = 0;
154 }
155 }
156 return $ret;
157 }
158
162 function fill( &$productArray )
163 {
164 $db =& eZDB::globalDatabase();
165 $this->ID = $productArray[$db->fieldName( "ID" )];
166 $this->Min = $productArray[$db->fieldName( "Min" )];
167 $this->Max = $productArray[$db->fieldName( "Max" )];
168 $this->ProductID = $productArray[$db->fieldName( "ProductID" )];
169 }
170
176 function &getAll( $offset=0, $limit=20 )
177 {
178 $db =& eZDB::globalDatabase();
179
180 $returnArray = array();
181 $productArray = array();
182
183 if ( $limit == false )
184 {
185 $db->array_query( $productArray, "SELECT ID
186 FROM eZTrade_ProductPriceRange
187 " );
188
189 }
190 else
191 {
192 $db->array_query( $productArray, "SELECT ID
193 FROM eZTrade_ProductPriceRange
194 ", array( "Limit" => $limit, "Offset" => $offset ) );
195 }
196
197 for ( $i=0; $i < count($productArray); $i++ )
198 {
199 $returnArray[$i] = new eZProductPriceRange( $productArray[$i][$db->fieldName( "ID" )] );
200 }
201
202 return $returnArray;
203 }
204
208 function count()
209 {
210 $db =& eZDB::globalDatabase();
211 $ret = false;
212
213 $db->query_single( $result, "SELECT COUNT(ID) as Count
214 FROM eZTrade_ProductPriceRange" );
215 $ret = $result[$db->fieldName( "Count" )];
216 return $ret;
217 }
218
222 function id()
223 {
224 return $this->ID;
225 }
226
230 function &min()
231 {
232 return $this->Min;
233 }
234
238 function &max()
239 {
240 return $this->Max;
241 }
242
246 function setMin( $value )
247 {
248 $this->Min = $value;
249 }
250
254 function setMax( $value )
255 {
256 $this->Max = $value;
257 }
258
262 function setProduct( $value )
263 {
264 if ( get_class ( $value ) )
265 {
266 $this->ProductID = $value->id();
267 }
268 else if ( is_numeric ( $value ) )
269 {
270 $this->ProductID = $value;
271 }
272 }
273
277 function product( $asObjcet=true )
278 {
279 if ( $asObject )
280 {
281 $ret = new eZProduct( $this->ProductID );
282 }
283 else
284 {
285 $ret = $this->ProductID;
286 }
287 return $ret;
288 }
289
290 var $ID;
291 var $Min;
292 var $Max;
293 var $ProductID;
294 }
295
296 ?>
$i
$i
Definition: admin/adlist.php:91
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZDateTime
Definition: ezdatetime.php:55
eZProductPriceRange
Definition: ezproductpricerange.php:48
eZProductPriceRange\count
count()
Definition: ezproductpricerange.php:208
eZProductPriceRange\id
id()
Definition: ezproductpricerange.php:222
eZProductPriceRange\setMax
setMax( $value)
Definition: ezproductpricerange.php:254
eZProductPriceRange\product
product( $asObjcet=true)
Definition: ezproductpricerange.php:277
eZProductPriceRange\__construct
__construct( $id=-1)
Definition: ezproductpricerange.php:56
eZProductPriceRange\setMin
setMin( $value)
Definition: ezproductpricerange.php:246
eZProductPriceRange\$ProductID
$ProductID
Definition: ezproductpricerange.php:293
eZProductPriceRange\fill
fill(&$productArray)
Definition: ezproductpricerange.php:162
eZProductPriceRange\setProduct
setProduct( $value)
Definition: ezproductpricerange.php:262
eZProductPriceRange\$Max
$Max
Definition: ezproductpricerange.php:292
eZProductPriceRange\$Min
$Min
Definition: ezproductpricerange.php:291
eZProductPriceRange\store
store()
Definition: ezproductpricerange.php:72
eZProductPriceRange\max
& max()
Definition: ezproductpricerange.php:238
eZProductPriceRange\min
& min()
Definition: ezproductpricerange.php:230
eZProductPriceRange\getAll
& getAll( $offset=0, $limit=20)
Definition: ezproductpricerange.php:176
eZProductPriceRange\$ID
$ID
Definition: ezproductpricerange.php:290
eZProduct
Definition: ezproduct.php:71
$result
$result
Definition: companysearch.php:94
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$limit
$limit
Definition: ezimagecatalogue/admin/imagelist.php:312
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
$offset
$offset
Definition: ezstats/admin/cron.php:51
$productArray
$productArray
Definition: productreport.php:74
Password
</td ></tr >< tr >< td style="color:<?= isset( $error['password1'] ) ?> Password
Definition: step1.php:146
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.