Development

/plugins/sfIpGeolocHelperPlugin/lib/model/om/BasecountryPeer.php

You must first sign up to be able to contribute.

root/plugins/sfIpGeolocHelperPlugin/lib/model/om/BasecountryPeer.php

Revision 17326, 25.3 kB (checked in by lombardot, 4 years ago)

[sfIpGeolocHelperPlugin] import version 1.0.1

Line 
1 <?php
2
3 /**
4  * Base static class for performing query and update operations on the 'country' table.
5  *
6  *
7  *
8  * This class was autogenerated by Propel 1.3.0-dev on:
9  *
10  * 04/15/09 12:27:10
11  *
12  * @package    plugins.sfIpGeolocHelperPlugin.lib.model.om
13  */
14 abstract class BasecountryPeer {
15
16     /** the default database name for this class */
17     const DATABASE_NAME = 'propel';
18
19     /** the table name for this class */
20     const TABLE_NAME = 'country';
21
22     /** A class that can be returned by this peer. */
23     const CLASS_DEFAULT = 'plugins.sfIpGeolocHelperPlugin.lib.model.country';
24
25     /** The total number of columns. */
26     const NUM_COLUMNS = 5;
27
28     /** The number of lazy-loaded columns. */
29     const NUM_LAZY_LOAD_COLUMNS = 0;
30
31     /** the column name for the ISO field */
32     const ISO = 'country.ISO';
33
34     /** the column name for the NAME field */
35     const NAME = 'country.NAME';
36
37     /** the column name for the PRINTABLE_NAME field */
38     const PRINTABLE_NAME = 'country.PRINTABLE_NAME';
39
40     /** the column name for the ISO3 field */
41     const ISO3 = 'country.ISO3';
42
43     /** the column name for the NUMCODE field */
44     const NUMCODE = 'country.NUMCODE';
45
46     /**
47      * An identiy map to hold any loaded instances of country objects.
48      * This must be public so that other peer classes can access this when hydrating from JOIN
49      * queries.
50      * @var        array country[]
51      */
52     public static $instances = array();
53
54     /**
55      * The MapBuilder instance for this peer.
56      * @var        MapBuilder
57      */
58     private static $mapBuilder = null;
59
60     /**
61      * holds an array of fieldnames
62      *
63      * first dimension keys are the type constants
64      * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
65      */
66     private static $fieldNames = array (
67         BasePeer::TYPE_PHPNAME => array ('Iso', 'Name', 'PrintableName', 'Iso3', 'Numcode', ),
68         BasePeer::TYPE_STUDLYPHPNAME => array ('iso', 'name', 'printableName', 'iso3', 'numcode', ),
69         BasePeer::TYPE_COLNAME => array (self::ISO, self::NAME, self::PRINTABLE_NAME, self::ISO3, self::NUMCODE, ),
70         BasePeer::TYPE_FIELDNAME => array ('iso', 'name', 'printable_name', 'iso3', 'numcode', ),
71         BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
72     );
73
74     /**
75      * holds an array of keys for quick access to the fieldnames array
76      *
77      * first dimension keys are the type constants
78      * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
79      */
80     private static $fieldKeys = array (
81         BasePeer::TYPE_PHPNAME => array ('Iso' => 0, 'Name' => 1, 'PrintableName' => 2, 'Iso3' => 3, 'Numcode' => 4, ),
82         BasePeer::TYPE_STUDLYPHPNAME => array ('iso' => 0, 'name' => 1, 'printableName' => 2, 'iso3' => 3, 'numcode' => 4, ),
83         BasePeer::TYPE_COLNAME => array (self::ISO => 0, self::NAME => 1, self::PRINTABLE_NAME => 2, self::ISO3 => 3, self::NUMCODE => 4, ),
84         BasePeer::TYPE_FIELDNAME => array ('iso' => 0, 'name' => 1, 'printable_name' => 2, 'iso3' => 3, 'numcode' => 4, ),
85         BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
86     );
87
88     /**
89      * Get a (singleton) instance of the MapBuilder for this peer class.
90      * @return     MapBuilder The map builder for this peer
91      */
92     public static function getMapBuilder()
93     {
94         if (self::$mapBuilder === null) {
95             self::$mapBuilder = new countryMapBuilder();
96         }
97         return self::$mapBuilder;
98     }
99     /**
100      * Translates a fieldname to another type
101      *
102      * @param      string $name field name
103      * @param      string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
104      *                         BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
105      * @param      string $toType   One of the class type constants
106      * @return     string translated name of the field.
107      * @throws     PropelException - if the specified name could not be found in the fieldname mappings.
108      */
109     static public function translateFieldName($name, $fromType, $toType)
110     {
111         $toNames = self::getFieldNames($toType);
112         $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
113         if ($key === null) {
114             throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
115         }
116         return $toNames[$key];
117     }
118
119     /**
120      * Returns an array of field names.
121      *
122      * @param      string $type The type of fieldnames to return:
123      *                      One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
124      *                      BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
125      * @return     array A list of field names
126      */
127
128     static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
129     {
130         if (!array_key_exists($type, self::$fieldNames)) {
131             throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
132         }
133         return self::$fieldNames[$type];
134     }
135
136     /**
137      * Convenience method which changes table.column to alias.column.
138      *
139      * Using this method you can maintain SQL abstraction while using column aliases.
140      * <code>
141      *        $c->addAlias("alias1", TablePeer::TABLE_NAME);
142      *        $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
143      * </code>
144      * @param      string $alias The alias for the current table.
145      * @param      string $column The column name for current table. (i.e. countryPeer::COLUMN_NAME).
146      * @return     string
147      */
148     public static function alias($alias, $column)
149     {
150         return str_replace(countryPeer::TABLE_NAME.'.', $alias.'.', $column);
151     }
152
153     /**
154      * Add all the columns needed to create a new object.
155      *
156      * Note: any columns that were marked with lazyLoad="true" in the
157      * XML schema will not be added to the select list and only loaded
158      * on demand.
159      *
160      * @param      criteria object containing the columns to add.
161      * @throws     PropelException Any exceptions caught during processing will be
162      *         rethrown wrapped into a PropelException.
163      */
164     public static function addSelectColumns(Criteria $criteria)
165     {
166
167         $criteria->addSelectColumn(countryPeer::ISO);
168
169         $criteria->addSelectColumn(countryPeer::NAME);
170
171         $criteria->addSelectColumn(countryPeer::PRINTABLE_NAME);
172
173         $criteria->addSelectColumn(countryPeer::ISO3);
174
175         $criteria->addSelectColumn(countryPeer::NUMCODE);
176
177     }
178
179     /**
180      * Returns the number of rows matching criteria.
181      *
182      * @param      Criteria $criteria
183      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
184      * @param      PropelPDO $con
185      * @return     int Number of matching rows.
186      */
187     public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
188     {
189         // we may modify criteria, so copy it first
190         $criteria = clone $criteria;
191
192         // We need to set the primary table name, since in the case that there are no WHERE columns
193         // it will be impossible for the BasePeer::createSelectSql() method to determine which
194         // tables go into the FROM clause.
195         $criteria->setPrimaryTableName(countryPeer::TABLE_NAME);
196
197         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
198             $criteria->setDistinct();
199         }
200
201         if (!$criteria->hasSelectClause()) {
202             countryPeer::addSelectColumns($criteria);
203         }
204
205         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
206         $criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName
207
208         if ($con === null) {
209             $con = Propel::getConnection(countryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
210         }
211
212
213     foreach (sfMixer::getCallables('BasecountryPeer:doCount:doCount') as $callable)
214     {
215       call_user_func($callable, 'BasecountryPeer', $criteria, $con);
216     }
217
218
219         // BasePeer returns a PDOStatement
220         $stmt = BasePeer::doCount($criteria, $con);
221
222         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
223             $count = (int) $row[0];
224         } else {
225             $count = 0; // no rows returned; we infer that means 0 matches.
226         }
227         $stmt->closeCursor();
228         return $count;
229     }
230     /**
231      * Method to select one object from the DB.
232      *
233      * @param      Criteria $criteria object used to create the SELECT statement.
234      * @param      PropelPDO $con
235      * @return     country
236      * @throws     PropelException Any exceptions caught during processing will be
237      *         rethrown wrapped into a PropelException.
238      */
239     public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
240     {
241         $critcopy = clone $criteria;
242         $critcopy->setLimit(1);
243         $objects = countryPeer::doSelect($critcopy, $con);
244         if ($objects) {
245             return $objects[0];
246         }
247         return null;
248     }
249     /**
250      * Method to do selects.
251      *
252      * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
253      * @param      PropelPDO $con
254      * @return     array Array of selected Objects
255      * @throws     PropelException Any exceptions caught during processing will be
256      *         rethrown wrapped into a PropelException.
257      */
258     public static function doSelect(Criteria $criteria, PropelPDO $con = null)
259     {
260         return countryPeer::populateObjects(countryPeer::doSelectStmt($criteria, $con));
261     }
262     /**
263      * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
264      *
265      * Use this method directly if you want to work with an executed statement durirectly (for example
266      * to perform your own object hydration).
267      *
268      * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
269      * @param      PropelPDO $con The connection to use
270      * @throws     PropelException Any exceptions caught during processing will be
271      *         rethrown wrapped into a PropelException.
272      * @return     PDOStatement The executed PDOStatement object.
273      * @see        BasePeer::doSelect()
274      */
275     public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
276     {
277
278     foreach (sfMixer::getCallables('BasecountryPeer:doSelectStmt:doSelectStmt') as $callable)
279     {
280       call_user_func($callable, 'BasecountryPeer', $criteria, $con);
281     }
282
283
284         if ($con === null) {
285             $con = Propel::getConnection(countryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
286         }
287
288         if (!$criteria->hasSelectClause()) {
289             $criteria = clone $criteria;
290             countryPeer::addSelectColumns($criteria);
291         }
292
293         // Set the correct dbName
294         $criteria->setDbName(self::DATABASE_NAME);
295
296         // BasePeer returns a PDOStatement
297         return BasePeer::doSelect($criteria, $con);
298     }
299     /**
300      * Adds an object to the instance pool.
301      *
302      * Propel keeps cached copies of objects in an instance pool when they are retrieved
303      * from the database.  In some cases -- especially when you override doSelect*()
304      * methods in your stub classes -- you may need to explicitly add objects
305      * to the cache in order to ensure that the same objects are always returned by doSelect*()
306      * and retrieveByPK*() calls.
307      *
308      * @param      country $value A country object.
309      * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
310      */
311     public static function addInstanceToPool(country $obj, $key = null)
312     {
313         if (Propel::isInstancePoolingEnabled()) {
314             if ($key === null) {
315                 $key = (string) $obj->getIso();
316             } // if key === null
317             self::$instances[$key] = $obj;
318         }
319     }
320
321     /**
322      * Removes an object from the instance pool.
323      *
324      * Propel keeps cached copies of objects in an instance pool when they are retrieved
325      * from the database.  In some cases -- especially when you override doDelete
326      * methods in your stub classes -- you may need to explicitly remove objects
327      * from the cache in order to prevent returning objects that no longer exist.
328      *
329      * @param      mixed $value A country object or a primary key value.
330      */
331     public static function removeInstanceFromPool($value)
332     {
333         if (Propel::isInstancePoolingEnabled() && $value !== null) {
334             if (is_object($value) && $value instanceof country) {
335                 $key = (string) $value->getIso();
336             } elseif (is_scalar($value)) {
337                 // assume we've been passed a primary key
338                 $key = (string) $value;
339             } else {
340                 $e = new PropelException("Invalid value passed to removeInstanceFromPool().  Expected primary key or country object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
341                 throw $e;
342             }
343
344             unset(self::$instances[$key]);
345         }
346     } // removeInstanceFromPool()
347
348     /**
349      * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
350      *
351      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
352      * a multi-column primary key, a serialize()d version of the primary key will be returned.
353      *
354      * @param      string $key The key (@see getPrimaryKeyHash()) for this instance.
355      * @return     country Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled.
356      * @see        getPrimaryKeyHash()
357      */
358     public static function getInstanceFromPool($key)
359     {
360         if (Propel::isInstancePoolingEnabled()) {
361             if (isset(self::$instances[$key])) {
362                 return self::$instances[$key];
363             }
364         }
365         return null; // just to be explicit
366     }
367     
368     /**
369      * Clear the instance pool.
370      *
371      * @return     void
372      */
373     public static function clearInstancePool()
374     {
375         self::$instances = array();
376     }
377     
378     /**
379      * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
380      *
381      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
382      * a multi-column primary key, a serialize()d version of the primary key will be returned.
383      *
384      * @param      array $row PropelPDO resultset row.
385      * @param      int $startcol The 0-based offset for reading from the resultset row.
386      * @return     string A string version of PK or NULL if the components of primary key in result array are all null.
387      */
388     public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
389     {
390         // If the PK cannot be derived from the row, return NULL.
391         if ($row[$startcol + 0] === null) {
392             return null;
393         }
394         return (string) $row[$startcol + 0];
395     }
396
397     /**
398      * The returned array will contain objects of the default type or
399      * objects that inherit from the default.
400      *
401      * @throws     PropelException Any exceptions caught during processing will be
402      *         rethrown wrapped into a PropelException.
403      */
404     public static function populateObjects(PDOStatement $stmt)
405     {
406         $results = array();
407     
408         // set the class once to avoid overhead in the loop
409         $cls = countryPeer::getOMClass();
410         $cls = substr('.'.$cls, strrpos('.'.$cls, '.') + 1);
411         // populate the object(s)
412         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
413             $key = countryPeer::getPrimaryKeyHashFromRow($row, 0);
414             if (null !== ($obj = countryPeer::getInstanceFromPool($key))) {
415                 // We no longer rehydrate the object, since this can cause data loss.
416                 // See http://propel.phpdb.org/trac/ticket/509
417                 // $obj->hydrate($row, 0, true); // rehydrate
418                 $results[] = $obj;
419             } else {
420         
421                 $obj = new $cls();
422                 $obj->hydrate($row);
423                 $results[] = $obj;
424                 countryPeer::addInstanceToPool($obj, $key);
425             } // if key exists
426         }
427         $stmt->closeCursor();
428         return $results;
429     }
430
431   static public function getUniqueColumnNames()
432   {
433     return array(array('name'), array('printable_name'));
434   }
435     /**
436      * Returns the TableMap related to this peer.
437      * This method is not needed for general use but a specific application could have a need.
438      * @return     TableMap
439      * @throws     PropelException Any exceptions caught during processing will be
440      *         rethrown wrapped into a PropelException.
441      */
442     public static function getTableMap()
443     {
444         return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
445     }
446
447     /**
448      * The class that the Peer will make instances of.
449      *
450      * This uses a dot-path notation which is tranalted into a path
451      * relative to a location on the PHP include_path.
452      * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
453      *
454      * @return     string path.to.ClassName
455      */
456     public static function getOMClass()
457     {
458         return countryPeer::CLASS_DEFAULT;
459     }
460
461     /**
462      * Method perform an INSERT on the database, given a country or Criteria object.
463      *
464      * @param      mixed $values Criteria or country object containing data that is used to create the INSERT statement.
465      * @param      PropelPDO $con the PropelPDO connection to use
466      * @return     mixed The new primary key.
467      * @throws     PropelException Any exceptions caught during processing will be
468      *         rethrown wrapped into a PropelException.
469      */
470     public static function doInsert($values, PropelPDO $con = null)
471     {
472
473     foreach (sfMixer::getCallables('BasecountryPeer:doInsert:pre') as $callable)
474     {
475       $ret = call_user_func($callable, 'BasecountryPeer', $values, $con);
476       if (false !== $ret)
477       {
478         return $ret;
479       }
480     }
481
482
483         if ($con === null) {
484             $con = Propel::getConnection(countryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
485         }
486
487         if ($values instanceof Criteria) {
488             $criteria = clone $values; // rename for clarity
489         } else {
490             $criteria = $values->buildCriteria(); // build Criteria from country object
491         }
492
493
494         // Set the correct dbName
495         $criteria->setDbName(self::DATABASE_NAME);
496
497         try {
498             // use transaction because $criteria could contain info
499             // for more than one table (I guess, conceivably)
500             $con->beginTransaction();
501             $pk = BasePeer::doInsert($criteria, $con);
502             $con->commit();
503         } catch(PropelException $e) {
504             $con->rollBack();
505             throw $e;
506         }
507
508         
509     foreach (sfMixer::getCallables('BasecountryPeer:doInsert:post') as $callable)
510     {
511       call_user_func($callable, 'BasecountryPeer', $values, $con, $pk);
512     }
513
514     return $pk;
515     }
516
517     /**
518      * Method perform an UPDATE on the database, given a country or Criteria object.
519      *
520      * @param      mixed $values Criteria or country object containing data that is used to create the UPDATE statement.
521      * @param      PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
522      * @return     int The number of affected rows (if supported by underlying database driver).
523      * @throws     PropelException Any exceptions caught during processing will be
524      *         rethrown wrapped into a PropelException.
525      */
526     public static function doUpdate($values, PropelPDO $con = null)
527     {
528
529     foreach (sfMixer::getCallables('BasecountryPeer:doUpdate:pre') as $callable)
530     {
531       $ret = call_user_func($callable, 'BasecountryPeer', $values, $con);
532       if (false !== $ret)
533       {
534         return $ret;
535       }
536     }
537
538
539         if ($con === null) {
540             $con = Propel::getConnection(countryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
541         }
542
543         $selectCriteria = new Criteria(self::DATABASE_NAME);
544
545         if ($values instanceof Criteria) {
546             $criteria = clone $values; // rename for clarity
547
548             $comparison = $criteria->getComparison(countryPeer::ISO);
549             $selectCriteria->add(countryPeer::ISO, $criteria->remove(countryPeer::ISO), $comparison);
550
551         } else { // $values is country object
552             $criteria = $values->buildCriteria(); // gets full criteria
553             $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
554         }
555
556         // set the correct dbName
557         $criteria->setDbName(self::DATABASE_NAME);
558
559         $ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
560     
561
562     foreach (sfMixer::getCallables('BasecountryPeer:doUpdate:post') as $callable)
563     {
564       call_user_func($callable, 'BasecountryPeer', $values, $con, $ret);
565     }
566
567     return $ret;
568   }
569
570     /**
571      * Method to DELETE all rows from the country table.
572      *
573      * @return     int The number of affected rows (if supported by underlying database driver).
574      */
575     public static function doDeleteAll($con = null)
576     {
577         if ($con === null) {
578             $con = Propel::getConnection(countryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
579         }
580         $affectedRows = 0; // initialize var to track total num of affected rows
581         try {
582             // use transaction because $criteria could contain info
583             // for more than one table or we could emulating ON DELETE CASCADE, etc.
584             $con->beginTransaction();
585             $affectedRows += BasePeer::doDeleteAll(countryPeer::TABLE_NAME, $con);
586             $con->commit();
587             return $affectedRows;
588         } catch (PropelException $e) {
589             $con->rollBack();
590             throw $e;
591         }
592     }
593
594     /**
595      * Method perform a DELETE on the database, given a country or Criteria object OR a primary key value.
596      *
597      * @param      mixed $values Criteria or country object or primary key or array of primary keys
598      *              which is used to create the DELETE statement
599      * @param      PropelPDO $con the connection to use
600      * @return     int     The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
601      *                if supported by native driver or if emulated using Propel.
602      * @throws     PropelException Any exceptions caught during processing will be
603      *         rethrown wrapped into a PropelException.
604      */
605      public static function doDelete($values, PropelPDO $con = null)
606      {
607         if ($con === null) {
608             $con = Propel::getConnection(countryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
609         }
610
611         if ($values instanceof Criteria) {
612             // invalidate the cache for all objects of this type, since we have no
613             // way of knowing (without running a query) what objects should be invalidated
614             // from the cache based on this Criteria.
615             countryPeer::clearInstancePool();
616
617             // rename for clarity
618             $criteria = clone $values;
619         } elseif ($values instanceof country) {
620             // invalidate the cache for this single object
621             countryPeer::removeInstanceFromPool($values);
622             // create criteria based on pk values
623             $criteria = $values->buildPkeyCriteria();
624         } else {
625             // it must be the primary key
626
627
628
629             $criteria = new Criteria(self::DATABASE_NAME);
630             $criteria->add(countryPeer::ISO, (array) $values, Criteria::IN);
631
632             foreach ((array) $values as $singleval) {
633                 // we can invalidate the cache for this single object
634                 countryPeer::removeInstanceFromPool($singleval);
635             }
636         }
637
638         // Set the correct dbName
639         $criteria->setDbName(self::DATABASE_NAME);
640
641         $affectedRows = 0; // initialize var to track total num of affected rows
642
643         try {
644             // use transaction because $criteria could contain info
645             // for more than one table or we could emulating ON DELETE CASCADE, etc.
646             $con->beginTransaction();
647             
648             $affectedRows += BasePeer::doDelete($criteria, $con);
649
650             $con->commit();
651             return $affectedRows;
652         } catch (PropelException $e) {
653             $con->rollBack();
654             throw $e;
655         }
656     }
657
658     /**
659      * Validates all modified columns of given country object.
660      * If parameter $columns is either a single column name or an array of column names
661      * than only those columns are validated.
662      *
663      * NOTICE: This does not apply to primary or foreign keys for now.
664      *
665      * @param      country $obj The object to validate.
666      * @param      mixed $cols Column name or array of column names.
667      *
668      * @return     mixed TRUE if all columns are valid or the error message of the first invalid column.
669      */
670     public static function doValidate(country $obj, $cols = null)
671     {
672         $columns = array();
673
674         if ($cols) {
675             $dbMap = Propel::getDatabaseMap(countryPeer::DATABASE_NAME);
676             $tableMap = $dbMap->getTable(countryPeer::TABLE_NAME);
677
678             if (! is_array($cols)) {
679                 $cols = array($cols);
680             }
681
682             foreach ($cols as $colName) {
683                 if ($tableMap->containsColumn($colName)) {
684                     $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
685                     $columns[$colName] = $obj->$get();
686                 }
687             }
688         } else {
689
690         }
691
692         $res BasePeer::doValidate(countryPeer::DATABASE_NAME, countryPeer::TABLE_NAME, $columns);
693     if ($res !== true) {
694         $request = sfContext::getInstance()->getRequest();
695         foreach ($res as $failed) {
696             $col = countryPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
697         }
698     }
699
700     return $res;
701     }
702
703     /**
704      * Retrieve a single object by pkey.
705      *
706      * @param      string $pk the primary key.
707      * @param      PropelPDO $con the connection to use
708      * @return     country
709      */
710     public static function retrieveByPK($pk, PropelPDO $con = null)
711     {
712
713         if (null !== ($obj = countryPeer::getInstanceFromPool((string) $pk))) {
714             return $obj;
715         }
716
717         if ($con === null) {
718             $con = Propel::getConnection(countryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
719         }
720
721         $criteria = new Criteria(countryPeer::DATABASE_NAME);
722         $criteria->add(countryPeer::ISO, $pk);
723
724         $v = countryPeer::doSelect($criteria, $con);
725
726         return !empty($v) > 0 ? $v[0] : null;
727     }
728
729     /**
730      * Retrieve multiple objects by pkey.
731      *
732      * @param      array $pks List of primary keys
733      * @param      PropelPDO $con the connection to use
734      * @throws     PropelException Any exceptions caught during processing will be
735      *         rethrown wrapped into a PropelException.
736      */
737     public static function retrieveByPKs($pks, PropelPDO $con = null)
738     {
739         if ($con === null) {
740             $con = Propel::getConnection(countryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
741         }
742
743         $objs = null;
744         if (empty($pks)) {
745             $objs = array();
746         } else {
747             $criteria = new Criteria(countryPeer::DATABASE_NAME);
748             $criteria->add(countryPeer::ISO, $pks, Criteria::IN);
749             $objs = countryPeer::doSelect($criteria, $con);
750         }
751         return $objs;
752     }
753
754 } // BasecountryPeer
755
756 // This is the static code needed to register the MapBuilder for this table with the main Propel class.
757 //
758 // NOTE: This static code cannot call methods on the countryPeer class, because it is not defined yet.
759 // If you need to use overridden methods, you can add this code to the bottom of the countryPeer class:
760 //
761 // Propel::getDatabaseMap(countryPeer::DATABASE_NAME)->addTableBuilder(countryPeer::TABLE_NAME, countryPeer::getMapBuilder());
762 //
763 // Doing so will effectively overwrite the registration below.
764
765 Propel::getDatabaseMap(BasecountryPeer::DATABASE_NAME)->addTableBuilder(BasecountryPeer::TABLE_NAME, BasecountryPeer::getMapBuilder());
766
767
Note: See TracBrowser for help on using the browser.