Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezregion.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezregion.php,v 1.10 2001/08/01 15:15:47 ghb Exp $
5 //
6 // Definition of eZRegion class
7 //
8 // Created on: <31-Oct-2001 11:49:30 ghb>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 2001-2005 Brookins Consulting. 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
35 // include_once( "classes/ezdb.php" );
36 // include_once( "classes/ezquery.php" );
37
38 class eZRegion
39 {
43 function __construct( $id = "" )
44 {
45 if ( is_array( $id ) )
46 {
47 $this->fill( $id );
48 }
49 else if ( $id != "" )
50 {
51 $this->ID = $id;
52 $this->get( $this->ID );
53 }
54 }
55
59 function store()
60 {
61 $db =& eZDB::globalDatabase();
62 $db->begin();
63 $name = $db->escapeString( $this->Name );
64 if ( !isset( $this->ID ) )
65 {
66 $db->lock( "eZAddress_Region" );
67 $this->ID = $db->nextID( "eZAddress_Region", "ID" );
68
69 $res[] = $db->query( "INSERT INTO eZAddress_Region
70 ( ID, CountryID, Abbreviation, Name, HasTax, Removed)
71 VALUES ( '$this->ID', '$this->CountryID', '$this->Abbreviation', '$this->Name', '$this->HasTax', '$this->Removed' )" );
72 $db->unlock();
73 }
74 else
75 {
76
77 $res[] = $db->query( "UPDATE eZAddress_Region
78 SET CountryID='$this->CountryID',
79 Abbreviation='$this->Abbreviation',
80 Name='$this->Name',
81 HasTax='$this->HasTax',
82 Removed='$this->Removed'
83 WHERE ID='$this->ID'" );
84
85 }
86 eZDB::finish( $res, $db );
87 return $dbError;
88 }
89
93 function get( $id="" )
94 {
95 $db =& eZDB::globalDatabase();
96 if ( $id != "" )
97 {
98 $db->array_query( $region_array, "SELECT * FROM eZAddress_Region WHERE ID='$id'" );
99
100 if ( count( $region_array ) == 1 )
101 {
102 $this->fill( $region_array[0] );
103 }
104 }
105 }
106
110 function fill( &$region_array )
111 {
112 $db =& eZDB::globalDatabase();
113
114 $this->ID =& $region_array[ $db->fieldName( "ID" ) ];
115 $this->CountryID =& $region_array[ $db->fieldName( "CountryID" ) ];
116 $this->Abbreviation =& $region_array[ $db->fieldName( "Abbreviation" ) ];
117 $this->Name =& $region_array[ $db->fieldName( "Name" ) ];
118 $this->HasTax =& $region_array[ $db->fieldName( "HasTax" ) ];
119 $this->Removed =& $region_array[ $db->fieldName( "Removed" ) ];
120 }
121
125 static public function &getAllCount( $search = "" )
126 {
127 $db =& eZDB::globalDatabase();
128 $search_arg = "";
129
130 if ( !empty( $search ) )
131 {
132 $query = new eZQuery( array( "Name", "Abbreviation" ), $search );
133 $search_arg = "AND " . $query->buildQuery();
134 // $search_arg = "WHERE Name like '%$search%'";
135 }
136
137 $db->query_single( $region_countries, "SELECT COUNT( ID ) as Count FROM eZAddress_Region
138 WHERE Removed=0 $search_arg
139 " );
140 return $region_countries[ $db->fieldName("Count") ];
141 }
142
146 static public function &getAll( $as_object = true, $search = "", $offset = 0, $max = -1 )
147 {
148 $db =& eZDB::globalDatabase();
149
150 $region_array = 0;
151 $return_array = array();
152 $limit = "";
153 $search_arg = "";
154
155 if ( $max >= 0 && is_numeric( $offset ) && is_numeric( $max ) )
156 {
157 $limit = array( "Limit" => $max,
158 "Offset" => $offset );
159 }
160
161 if ( !empty( $search ) )
162 {
163 $query = new eZQuery( array( "Name", "Abbreviation" ), $search );
164 $search_arg = "AND " . $query->buildQuery();
165 // $search_arg = "WHERE Name like '%$search%'";
166 }
167
168 if ( $as_object )
169 $select = "*";
170 else
171 $select = "ID";
172
173 $db->array_query( $region_array, "SELECT $select FROM eZAddress_Region
174 WHERE Removed=0 $search_arg
175 ORDER BY Name", $limit );
176
177 if ( $as_object )
178 {
179 foreach ( $region_array as $region )
180 {
181 $return_array[] = new eZRegion( $region[ $db->fieldName( "ID" ) ] );
182 }
183 }
184 else
185 {
186 foreach ( $region_array as $region )
187 {
188 $return_array[] = $region[ $db->fieldName( "ID" ) ];
189 }
190 }
191
192 return $return_array;
193
194 }
195
199 static public function &getAllArray( )
200 {
201 $db =& eZDB::globalDatabase();
202 $region_array = 0;
203 $return_array = array();
204
205 $db->array_query( $region_array, "SELECT * FROM eZAddress_Region
206 WHERE Removed=0
207 ORDER BY Name" );
208
209 foreach ( $region_array as $region )
210 {
211 $return_array[] = array( "ID" => $region[ $db->fieldName( "ID" ) ],
212 "CountryID" => $region[ $db->fieldName( "CountryID" ) ],
213 "Abbreviation" => $region[ $db->fieldName( "Abbreviation" ) ],
214 "Name" => $region[ $db->fieldName( "Name" ) ],
215 "HasTax" => $region[ $db->fieldName( "HasTax" ) ],
216 "Removed" => $region[ $db->fieldName( "Removed" ) ] );
217
218
219 }
220 return $return_array;
221 }
222
226 function delete( $id = false)
227 {
228 if ( !$id )
229 $id = $this->ID;
230 $db =& eZDB::globalDatabase();
231
232 $db->begin();
233 $res[] = $db->query( "DELETE FROM eZAddress_Region WHERE ID='$id'" );
234 eZDB::finish( $res, $db );
235 }
236
237
238 static public function &getCountryArray( $RequestedCountry=240 )
239 {
240 $db =& eZDB::globalDatabase();
241 $region_array = 0;
242
243 $db->array_query( $region_array, "SELECT * FROM eZAddress_Region
244 WHERE Removed=0 AND CountryID=$RequestedCountry
245 ORDER BY Name" );
246
247 if (sizeOf($region_array) == 0)
248 {
249 $region_array[] = array (
250 "ID" => -1,
251 "CountryID" => 0,
252 "Abbreviation" => "NONE",
253 "Name" => "No Regions Listed for Country",
254 "HasTax" => "0",
255 "Removed" => "0"
256 );
257 }
258
259
260 return $region_array;
261 }
262
263
264
268 function id( )
269 {
270 return $this->ID;
271 }
272
277 function name( )
278 {
279 return $this->Name;
280 }
281
285 function setName( $value )
286 {
287 $this->Name = $value;
288 }
289
293 function countryId( )
294 {
295 return $this->CountryID;
296 }
297
301 function setCountryId( $value )
302 {
303 $this->CountryID = $value;
304 }
305
309 function Abbreviation( )
310 {
311 return $this->Abbreviation;
312 }
313
317 function setAbbreviation( $value )
318 {
319 $this->Abbreviation = $value;
320 }
321
325 function hasVAT( )
326 {
327 if ( $this->HasTax == 1 )
328 return true;
329 else
330 return false;
331 }
332
336 function setHasVAT( $value )
337 {
338 if ( $value )
339 $this->HasTax = 1;
340 else
341 $this->HasTax = 0;
342 }
343
347 function removed( )
348 {
349 return $this->Removed;
350 }
351
355 function setRemoved( $value )
356 {
357 $this->Removed = $value;
358 }
359
360 var $ID;
361 var $CountryID;
362 var $Name;
363 var $Abbreviation;
364 var $HasTax;
365 var $Removed;
366 }
367
368 ?>
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZQuery
Definition: ezquery.php:54
eZRegion
Definition: ezregion.php:39
eZRegion\getCountryArray
static & getCountryArray( $RequestedCountry=240)
Definition: ezregion.php:238
eZRegion\setName
setName( $value)
Definition: ezregion.php:285
eZRegion\fill
fill(&$region_array)
Definition: ezregion.php:110
eZRegion\hasVAT
hasVAT()
Definition: ezregion.php:325
eZRegion\setHasVAT
setHasVAT( $value)
Definition: ezregion.php:336
eZRegion\__construct
__construct( $id="")
Definition: ezregion.php:43
eZRegion\getAll
static & getAll( $as_object=true, $search="", $offset=0, $max=-1)
Definition: ezregion.php:146
eZRegion\$ID
$ID
Definition: ezregion.php:360
eZRegion\setAbbreviation
setAbbreviation( $value)
Definition: ezregion.php:317
eZRegion\Abbreviation
Abbreviation()
Definition: ezregion.php:309
eZRegion\countryId
countryId()
Definition: ezregion.php:293
eZRegion\$HasTax
$HasTax
Definition: ezregion.php:364
eZRegion\removed
removed()
Definition: ezregion.php:347
eZRegion\id
id()
Definition: ezregion.php:268
eZRegion\$CountryID
$CountryID
Definition: ezregion.php:361
eZRegion\$Abbreviation
$Abbreviation
Definition: ezregion.php:363
eZRegion\$Name
$Name
Definition: ezregion.php:362
eZRegion\setRemoved
setRemoved( $value)
Definition: ezregion.php:355
eZRegion\getAllArray
static & getAllArray()
Definition: ezregion.php:199
eZRegion\getAllCount
static & getAllCount( $search="")
Definition: ezregion.php:125
eZRegion\$Removed
$Removed
Definition: ezregion.php:365
eZRegion\store
store()
Definition: ezregion.php:59
eZRegion\name
name()
Definition: ezregion.php:277
eZRegion\setCountryId
setCountryId( $value)
Definition: ezregion.php:301
$name
$name
Definition: companytypelist.php:194
$id
$id
Definition: companytypelist.php:193
$query
if(isset( $Year) &&!is_numeric( $Year)||isset( $Month) &&!is_numeric( $Month)) $query
Definition: entryexitpages.php:65
$search
$search
Definition: export_froogle.php:153
$db
$db
Definition: ezarticle/user/authorlist.php:53
$limit
$limit
Definition: ezimagecatalogue/admin/imagelist.php:312
$res
$res
Definition: ezstats/admin/cron.php:45
$offset
$offset
Definition: ezstats/admin/cron.php:51
$region
$region
Definition: paypal.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+.