Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezcartoptionvalue.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezcartoptionvalue.php 6856 2001-09-03 12:27:23Z ce $
5 //
6 // Definition of eZCartOptionValue class
7 //
8 // Created on: <27-Sep-2000 15:19:13 bf>
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 //
30
35 // include_once( "classes/ezdb.php" );
36
37 // include_once( "eztrade/classes/ezcartitem.php" );
38 // include_once( "eztrade/classes/ezoption.php" );
39 // include_once( "eztrade/classes/ezoptionvalue.php" );
40
41
42 class eZCartOptionValue
43 {
50 function __construct( $id="" )
51 {
52 if ( $id != "" )
53 {
54 $this->ID = $id;
55 $this->get( $this->ID );
56 }
57 else
58 {
59 $this->Count = 1;
60 }
61 }
62
66 function store()
67 {
68 $db =& eZDB::globalDatabase();
69 $db->begin();
70
71 if ( !isset( $this->ID ) )
72 {
73 $db->lock( "eZTrade_CartOptionValue" );
74 $nextID = $db->nextID( "eZTrade_CartOptionValue", "ID" );
75
76 $res = $db->query( "INSERT INTO eZTrade_CartOptionValue
77 ( ID, CartItemID, OptionID, RemoteID, OptionValueID, Count )
78 VALUES ( '$nextID','$this->CartItemID','$this->OptionID','$this->RemoteID','$this->OptionValueID', '$this->Count' )
79 " );
80 $db->unlock();
81
82 $this->ID = $nextID;
83 }
84 else
85 {
86 $res = $db->query( "UPDATE eZTrade_CartOptionValue SET
87 CartItemID='$this->CartItemID',
88 OptionID='$this->OptionID',
89 OptionValueID='$this->OptionValueID',
90 Count='$this->Count'
91 WHERE ID='$this->ID'
92 " );
93 }
94
95 if ( $res == false )
96 $db->rollback( );
97 else
98 $db->commit();
99
100 return true;
101 }
102
106 function get( $id="" )
107 {
108 $db =& eZDB::globalDatabase();
109 $ret = false;
110
111 if ( $id != "" )
112 {
113 $db->array_query( $cart_array, "SELECT * FROM eZTrade_CartOptionValue WHERE ID='$id'" );
114 if ( count( $cart_array ) > 1 )
115 {
116 die( "Error: Cart's with the same ID was found in the database. This shouldent happen." );
117 }
118 else if( count( $cart_array ) == 1 )
119 {
120 $this->ID =& $cart_array[0][$db->fieldName( "ID" )];
121 $this->CartItemID =& $cart_array[0][$db->fieldName( "CartItemID" )];
122 $this->OptionID =& $cart_array[0][$db->fieldName( "OptionID" )];
123 $this->RemoteID =& $cart_array[0][$db->fieldName( "RemoteID" )];
124 $this->OptionValueID =& $cart_array[0][$db->fieldName( "OptionValueID" )];
125 $this->Count =& $cart_array[0][$db->fieldName( "Count" )];
126
127 $ret = true;
128 }
129 }
130 return $ret;
131 }
132
137 function delete()
138 {
139 $db =& eZDB::globalDatabase();
140 $db->begin();
141
142 $res[] = $db->query( "DELETE FROM eZTrade_CartOptionValue WHERE ID='$this->ID'" );
143
144 if ( in_array( false, $res ) )
145 $db->rollback( );
146 else
147 $db->commit();
148
149 return true;
150 }
151
152
156 function id( )
157 {
158 return $this->ID;
159 }
160
164 function remoteID( )
165 {
166 return $this->RemoteID;
167 }
168
172 function &cartItem()
173 {
174 return new eZCartItem( $this->CartItemID );
175 }
176
180 function &option()
181 {
182 return new eZOption( $this->OptionID );
183 }
184
188 function &optionValue()
189 {
190 return new eZOptionValue( $this->OptionValueID );
191 }
192
196 function count()
197 {
198 return $this->Count;
199 }
200
204 function setCartItem( &$cartItem )
205 {
206 if ( is_a( $cartItem, "eZCartItem" ) )
207 {
208 $this->CartItemID = $cartItem->id();
209 }
210 }
211
215 function setOption( &$option )
216 {
217 if ( is_a( $option, "eZOption" ) )
218 {
219 $this->OptionID = $option->id();
220 }
221 }
222
226 function setRemoteID( $value )
227 {
228 $this->RemoteID = $value;
229 }
230
234 function setCount( $value )
235 {
236 $this->Count = $value;
237 }
238
242 function setOptionValue( &$optionValue )
243 {
244 if ( is_a( $optionValue, "eZOptionValue" ) )
245 {
246 $this->OptionValueID = $optionValue->id();
247 }
248 }
249
250 var $ID;
251 var $CartItemID;
252 var $OptionID;
253 var $OptionValueID;
254 var $RemoteID;
255 var $Count;
256 }
257
258 ?>
eZCartItem
Definition: ezcartitem.php:56
eZCartOptionValue
Definition: ezcartoptionvalue.php:43
eZCartOptionValue\cartItem
& cartItem()
Definition: ezcartoptionvalue.php:172
eZCartOptionValue\option
& option()
Definition: ezcartoptionvalue.php:180
eZCartOptionValue\setOption
setOption(&$option)
Definition: ezcartoptionvalue.php:215
eZCartOptionValue\$OptionID
$OptionID
Definition: ezcartoptionvalue.php:252
eZCartOptionValue\setRemoteID
setRemoteID( $value)
Definition: ezcartoptionvalue.php:226
eZCartOptionValue\$OptionValueID
$OptionValueID
Definition: ezcartoptionvalue.php:253
eZCartOptionValue\$Count
$Count
Definition: ezcartoptionvalue.php:255
eZCartOptionValue\count
count()
Definition: ezcartoptionvalue.php:196
eZCartOptionValue\$RemoteID
$RemoteID
Definition: ezcartoptionvalue.php:254
eZCartOptionValue\$ID
$ID
Definition: ezcartoptionvalue.php:250
eZCartOptionValue\setOptionValue
setOptionValue(&$optionValue)
Definition: ezcartoptionvalue.php:242
eZCartOptionValue\optionValue
& optionValue()
Definition: ezcartoptionvalue.php:188
eZCartOptionValue\setCartItem
setCartItem(&$cartItem)
Definition: ezcartoptionvalue.php:204
eZCartOptionValue\id
id()
Definition: ezcartoptionvalue.php:156
eZCartOptionValue\remoteID
remoteID()
Definition: ezcartoptionvalue.php:164
eZCartOptionValue\store
store()
Definition: ezcartoptionvalue.php:66
eZCartOptionValue\__construct
__construct( $id="")
Definition: ezcartoptionvalue.php:50
eZCartOptionValue\setCount
setCount( $value)
Definition: ezcartoptionvalue.php:234
eZCartOptionValue\$CartItemID
$CartItemID
Definition: ezcartoptionvalue.php:251
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZOptionValue
Definition: ezoptionvalue.php:54
eZOption
Definition: ezoption.php:82
$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+.