Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezproducttype.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezproducttype.php 6318 2001-07-31 11:33:12Z jhe $
5 //
6 // Definition of eZProductType class
7 //
8 // Created on: <20-Dec-2000 13:31:12 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 //
28
29
32
42 // include_once( "classes/ezdb.php" );
43 // include_once( "eztrade/classes/ezproductattribute.php" );
44
45 class eZProductType
46 {
51 function __construct( $id=-1, $fetch=true )
52 {
53 if ( $id != -1 )
54 {
55 $this->ID = $id;
56 $this->get( $this->ID );
57 }
58 }
59
63 function store()
64 {
65 $db =& eZDB::globalDatabase();
66 $db->begin();
67
68 $this->Name = $db->escapeString( $this->Name );
69 $this->Description = $db->escapeString( $this->Description );
70
71 if ( !isset( $this->ID ) )
72 {
73 $db->lock( "eZTrade_Type" );
74 $nextID = $db->nextID( "eZTrade_Type", "ID" );
75 $res[] = $db->query( "INSERT INTO eZTrade_Type
76 ( ID,
77 Name,
78 Description )
79 VALUES
80 ( '$nextID',
81 '$this->Name',
82 '$this->Description' )" );
83 $db->unlock();
84 $this->ID = $nextID;
85 }
86 else
87 {
88 $res[] = $db->query( "UPDATE eZTrade_Type SET
89 Name='$this->Name',
90 Description='$this->Description' WHERE ID='$this->ID'" );
91 }
92
93 eZDB::finish( $res, $db );
94 return true;
95 }
96
100 function get( $id=-1 )
101 {
102 $db =& eZDB::globalDatabase();
103
104 $ret = false;
105 if ( $id != -1 )
106 {
107 $db->array_query( $type_array, "SELECT * FROM eZTrade_Type WHERE ID='$id'" );
108
109 if ( count( $type_array ) > 1 )
110 {
111 die( "Error: Product type's with the same ID was found in the database. This shouldent happen." );
112 }
113 else if( count( $type_array ) == 1 )
114 {
115 $this->ID =& $type_array[0][$db->fieldName( "ID" )];
116 $this->Name =& $type_array[0][$db->fieldName( "Name" )];
117 $this->Description =& $type_array[0][$db->fieldName( "Description" )];
118
119 $ret = true;
120 }
121 }
122
123 return $ret;
124 }
125
129 function &getAll()
130 {
131 $db =& eZDB::globalDatabase();
132
133 $return_array = array();
134 $type_array = array();
135
136 $db->array_query( $type_array, "SELECT ID FROM eZTrade_Type ORDER BY Name" );
137
138 for ( $i=0; $i<count($type_array); $i++ )
139 {
140 $return_array[$i] = new eZProductType( $type_array[$i][$db->fieldName( "ID" )], 0 );
141 }
142
143 return $return_array;
144 }
145
149 function delete()
150 {
151 $db =& eZDB::globalDatabase();
152 $db->begin();
153
154 // delete all attributes and values
155 $attributes = $this->attributes();
156 foreach ( $attributes as $attribute )
157 {
158 $attribute->delete();
159 }
160
161 $res[] = $db->query( "DELETE FROM eZTrade_ProductTypeLink WHERE TypeID='$this->ID'" );
162 $res[] = $db->query( "DELETE FROM eZTrade_Type WHERE ID='$this->ID'" );
163
164 eZDB::finish( $res, $db );
165 }
166
170 function id()
171 {
172 return $this->ID;
173 }
174
178 function name()
179 {
180 return $this->Name;
181 }
182
186 function description()
187 {
188 return $this->Description;
189 }
190
194 function setName( $value )
195 {
196 $this->Name = $value;
197 }
198
202 function setDescription( $value )
203 {
204 $this->Description = $value;
205 }
206
211 function attributes( )
212 {
213 $db =& eZDB::globalDatabase();
214
215 $return_array = array();
216 $attribute_array = array();
217
218 $db->array_query( $attribute_array, "SELECT ID
219 FROM eZTrade_Attribute
220 WHERE TypeID='$this->ID' ORDER BY Placement" );
221
222 for ( $i=0; $i<count($attribute_array); $i++ )
223 {
224 $return_array[$i] = new eZProductAttribute( $attribute_array[$i][$db->fieldName( "ID" )], false );
225 }
226
227 return $return_array;
228 }
229
230
231 var $ID;
232 var $Name;
233 var $Description;
234
235 }
236
237 ?>
$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
eZProductAttribute
Definition: ezproductattribute.php:49
eZProductType
Definition: ezproducttype.php:46
eZProductType\getAll
& getAll()
Definition: ezproducttype.php:129
eZProductType\$ID
$ID
Definition: ezproducttype.php:231
eZProductType\$Description
$Description
Definition: ezproducttype.php:233
eZProductType\id
id()
Definition: ezproducttype.php:170
eZProductType\store
store()
Definition: ezproducttype.php:63
eZProductType\name
name()
Definition: ezproducttype.php:178
eZProductType\__construct
__construct( $id=-1, $fetch=true)
Definition: ezproducttype.php:51
eZProductType\setName
setName( $value)
Definition: ezproducttype.php:194
eZProductType\setDescription
setDescription( $value)
Definition: ezproducttype.php:202
eZProductType\description
description()
Definition: ezproducttype.php:186
eZProductType\$Name
$Name
Definition: ezproducttype.php:232
eZProductType\attributes
attributes()
Definition: ezproducttype.php:211
$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+.