Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezcountry.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezcountry.php 6339 2001-08-01 15:15:48Z ce $
5 //
6 // Definition of eZCountry class
7 //
8 // Created on: <31-Oct-2000 11:49:30 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
31
35 // include_once( "classes/ezdb.php" );
36 // include_once( "classes/ezquery.php" );
37
38 class eZCountry
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_Country" );
67 $this->ID = $db->nextID( "eZAddress_Country", "ID" );
68
69 $res[] = $db->query( "INSERT INTO eZAddress_Country
70 ( ID, ISO, Name, HasVAT )
71 VALUES ( '$this->ID', '$this->ISO', '$name', $this->HasVAT )" );
72 $db->unlock();
73 }
74 else
75 {
76 $res[] = $db->query( "UPDATE eZAddress_Country
77 SET ISO='$this->ISO',
78 Name='$name',
79 HasVAT='$this->HasVAT'
80 WHERE ID='$this->ID'" );
81
82 }
83 eZDB::finish( $res, $db );
84 return $dbError;
85 }
86
90 function get( $id="" )
91 {
92 $db =& eZDB::globalDatabase();
93 if ( $id != "" )
94 {
95 $db->array_query( $country_array, "SELECT * FROM eZAddress_Country WHERE ID='$id'" );
96 if ( count( $country_array ) == 1 )
97 {
98 $this->fill( $country_array[0] );
99 }
100 }
101 }
102
106 function fill( &$country_array )
107 {
108 $db =& eZDB::globalDatabase();
109
110 $this->ID =& $country_array[ $db->fieldName( "ID" ) ];
111 $this->ISO =& $country_array[ $db->fieldName( "ISO" ) ];
112 $this->Name =& $country_array[ $db->fieldName( "Name" ) ];
113 $this->HasVAT =& $country_array[ $db->fieldName( "HasVAT" ) ];
114 }
115
119 static public function &getAllCount( $search = "" )
120 {
121 $db =& eZDB::globalDatabase();
122
123 if ( !empty( $search ) )
124 {
125 $query = new eZQuery( array( "Name", "ISO" ), $search );
126 $search_arg = "AND " . $query->buildQuery();
127 // $search_arg = "WHERE Name like '%$search%'";
128 }
129 else
130 {
131 $search_arg = '';
132 }
133
134 $db->query_single( $countries, "SELECT COUNT( ID ) as Count FROM eZAddress_Country
135 WHERE Removed=0 $search_arg
136 " );
137 return $countries[ $db->fieldName("Count") ];
138 }
139
143 static public function &getAll( $as_object = true, $search = "", $offset = 0, $max = -1 )
144 {
145 $db =& eZDB::globalDatabase();
146
147 $country_array = 0;
148 $return_array = array();
149
150 if ( $max >= 0 && is_numeric( $offset ) && is_numeric( $max ) )
151 {
152 $limit = array( "Limit" => $max,
153 "Offset" => $offset );
154 }
155
156 if ( !empty( $search ) )
157 {
158 $query = new eZQuery( array( "Name", "ISO" ), $search );
159 $search_arg = "AND " . $query->buildQuery();
160 // $search_arg = "WHERE Name like '%$search%'";
161 }
162 else
163 {
164 $search_arg = '';
165 }
166
167 if ( $as_object )
168 $select = "*";
169 else
170 $select = "ID";
171
172 $db->array_query( $country_array, "SELECT $select FROM eZAddress_Country
173 WHERE Removed=0 $search_arg
174 ORDER BY Name", $limit );
175
176 if ( $as_object )
177 {
178 foreach ( $country_array as $country )
179 {
180 $return_array[] = new eZCountry( $country[ $db->fieldName( "ID" ) ] );
181 }
182 }
183 else
184 {
185 foreach ( $country_array as $country )
186 {
187 $return_array[] = $country[ $db->fieldName( "ID" ) ];
188 }
189 }
190 return $return_array;
191 }
192
196 static public function &getAllArray( )
197 {
198 $db =& eZDB::globalDatabase();
199 $country_array = 0;
200 $return_array = array();
201
202 $db->array_query( $country_array, "SELECT * FROM eZAddress_Country
203 WHERE Removed=0
204 ORDER BY Name" );
205 foreach ( $country_array as $country )
206 {
207 $return_array[] = array( "ID" => $country[ $db->fieldName( "ID" ) ],
208 "ISO" => $country[ $db->fieldName( "ISO" ) ],
209 "Name" => $country[ $db->fieldName( "Name" ) ],
210 "Removed" => $country[ $db->fieldName( "Removed" ) ] );
211 }
212 return $return_array;
213 }
214
218 function delete( $id = false)
219 {
220 if ( !$id )
221 $id = $this->ID;
222 $db =& eZDB::globalDatabase();
223
224 $db->begin();
225 $res[] = $db->query( "DELETE FROM eZAddress_Country WHERE ID='$id'" );
226 eZDB::finish( $res, $db );
227 }
228
229
233 function id( )
234 {
235 return $this->ID;
236 }
237
241 function iso( )
242 {
243 return $this->ISO;
244 }
245
249 function name( )
250 {
251 return $this->Name;
252 }
253
257 function hasVAT( )
258 {
259 if ( $this->HasVAT == 1 )
260 return true;
261 else
262 return false;
263 }
264
268 function setISO( $value )
269 {
270 $this->ISO = $value;
271 }
272
276 function setName( $value )
277 {
278 $this->Name = $value;
279 }
280
284 function setHasVAT( $value )
285 {
286 if ( $value )
287 $this->HasVAT = 1;
288 else
289 $this->HasVAT = 0;
290 }
291
292
293 var $ID;
294 var $ISO;
295 var $Name;
296 var $HasVAT;
297 }
298
299 ?>
eZCountry
Definition: ezcountry.php:39
eZCountry\$ID
$ID
Definition: ezcountry.php:293
eZCountry\hasVAT
hasVAT()
Definition: ezcountry.php:257
eZCountry\iso
iso()
Definition: ezcountry.php:241
eZCountry\getAllArray
static & getAllArray()
Definition: ezcountry.php:196
eZCountry\__construct
__construct( $id="")
Definition: ezcountry.php:43
eZCountry\$ISO
$ISO
Definition: ezcountry.php:294
eZCountry\setISO
setISO( $value)
Definition: ezcountry.php:268
eZCountry\name
name()
Definition: ezcountry.php:249
eZCountry\getAll
static & getAll( $as_object=true, $search="", $offset=0, $max=-1)
Definition: ezcountry.php:143
eZCountry\id
id()
Definition: ezcountry.php:233
eZCountry\setHasVAT
setHasVAT( $value)
Definition: ezcountry.php:284
eZCountry\$HasVAT
$HasVAT
Definition: ezcountry.php:296
eZCountry\store
store()
Definition: ezcountry.php:59
eZCountry\$Name
$Name
Definition: ezcountry.php:295
eZCountry\setName
setName( $value)
Definition: ezcountry.php:276
eZCountry\getAllCount
static & getAllCount( $search="")
Definition: ezcountry.php:119
eZCountry\fill
fill(&$country_array)
Definition: ezcountry.php:106
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZQuery
Definition: ezquery.php:54
$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
$country
$country
Definition: paypal.php:46
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+.