Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezvoucherpricerange.php
Go to the documentation of this file.
1 <?
3 //
4 // $Id: ezvoucherpricerange.php 7124 2001-09-10 12:39:28Z ce $
5 //
6 // eZProductPricerange class
7 //
8 // Christoffer A. Elo <ce@ez.no>
9 // Created on: <06-Sep-2001 09:46:53 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
78 if ( !isset( $this->ID ) )
79 {
80 $db->lock( "eZTrade_ProductPriceRange" );
81 $nextID = $db->nextID( "eZTrade_ProductPriceRange", "ID" );
82 $timeStamp =& (new eZDateTime())->timeStamp( true );
83 $password = md5( $this->Password );
84
85 $res = $db->query( "INSERT INTO eZTrade_ProductPriceRange
86 ( ID, Max, Min, ProductID )
87 VALUES
88 ( '$nextID',
89 '$this->Max',
90 '$this->Min',
91 '$this->ProductID'
92 )" );
93
94 $this->ID = $nextID;
95 }
96 elseif ( is_numeric( $this->ID ) )
97 {
98 $res = $db->query( "UPDATE eZTrade_ProductPriceRange SET
99 Min='$this->Min',
100 Max='$this->Max',
101 ProductID='$this->ProductID'
102 WHERE ID='$this->ID'" );
103 }
104 $db->unlock();
105
106 if ( $res == false )
107 $db->rollback( );
108 else
109 $db->commit();
110
111 return true;
112 }
113
117 function delete( $catID=-1 )
118 {
119 if ( $catID == -1 )
120 $catID = $this->ID;
121
122 $db =& eZDB::globalDatabase();
123 $db->begin();
124
125 $res = $db->query( "DELETE FROM eZTrade_ProductPriceRange WHERE ID='$this->ID'" );
126
127 if ( $ret == false )
128 $db->rollback( );
129 else
130 $db->commit();
131 }
132
138 function get( $id=-1 )
139 {
140 $db =& eZDB::globalDatabase();
141
142 $ret = false;
143 if ( $id != "" )
144 {
145 $db->array_query( $productArray, "SELECT * FROM eZTrade_ProductPriceRange WHERE ID='$id'",
146 0, 1 );
147 if( count( $productArray ) == 1 )
148 {
149 $this->fill( &$productArray[0] );
150 $ret = true;
151 }
152 elseif( count( $productArray ) == 1 )
153 {
154 $this->ID = 0;
155 }
156 }
157 return $ret;
158 }
159
163 function fill( &$productArray )
164 {
165 $this->ID =& $productArray[ "ID" ];
166 $this->Min =& $productArray[ "Min" ];
167 $this->Max =& $productArray[ "Max" ];
168 $this->ProductID =& $productArray[ "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 setProduct( $value )
247 {
248 if ( get_class ( $value ) )
249 {
250 $this->ProductID = $value->id();
251 }
252 else if ( is_numeric ( $value ) )
253 {
254 $this->ProductID = $value;
255 }
256 }
257
261 function product( $asObjcet=true )
262 {
263 if ( $asObject )
264 {
265 $ret = new eZProduct( $this->ProductID );
266 }
267 else
268 {
269 $ret = $this->ProductID;
270 }
271 return $ret;
272 }
273
274 var $ID;
275 var $Min;
276 var $Max;
277 var $ProductID;
278 }
279
280 ?>
$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: ezvoucherpricerange.php:222
eZProductPriceRange\product
product( $asObjcet=true)
Definition: ezvoucherpricerange.php:261
eZProductPriceRange\__construct
__construct( $id=-1)
Definition: ezvoucherpricerange.php:56
eZProductPriceRange\$ProductID
$ProductID
Definition: ezproductpricerange.php:293
eZProductPriceRange\fill
fill(&$productArray)
Definition: ezproductpricerange.php:162
eZProductPriceRange\setProduct
setProduct( $value)
Definition: ezvoucherpricerange.php:246
eZProductPriceRange\$Max
$Max
Definition: ezproductpricerange.php:292
eZProductPriceRange\$Min
$Min
Definition: ezproductpricerange.php:291
eZProductPriceRange\store
store()
Definition: ezvoucherpricerange.php:72
eZProductPriceRange\max
& max()
Definition: ezvoucherpricerange.php:238
eZProductPriceRange\min
& min()
Definition: ezvoucherpricerange.php:230
eZProductPriceRange\getAll
& getAll( $offset=0, $limit=20)
Definition: ezvoucherpricerange.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+.