Development

/plugins/sfFlickrGalleryPlugin/lib/model/om/BaseFphotosetPeer.php

You must first sign up to be able to contribute.

root/plugins/sfFlickrGalleryPlugin/lib/model/om/BaseFphotosetPeer.php

Revision 3879, 10.3 kB (checked in by Xavier.Luthi, 6 years ago)

Initial import of sfFlickrGalleryPlugin (version 0.1.0)

Line 
1 <?php
2
3
4 abstract class BaseFphotosetPeer {
5
6     
7     const DATABASE_NAME = 'propel';
8
9     
10     const TABLE_NAME = 'fphotoset';
11
12     
13     const CLASS_DEFAULT = 'plugins.sfFlickrGallery.lib.model.Fphotoset';
14
15     
16     const NUM_COLUMNS = 9;
17
18     
19     const NUM_LAZY_LOAD_COLUMNS = 0;
20
21
22     
23     const ID = 'fphotoset.ID';
24
25     
26     const FLICKRID = 'fphotoset.FLICKRID';
27
28     
29     const CONTENT_DATE = 'fphotoset.CONTENT_DATE';
30
31     
32     const URL = 'fphotoset.URL';
33
34     
35     const TITLE = 'fphotoset.TITLE';
36
37     
38     const DESCRIPTION = 'fphotoset.DESCRIPTION';
39
40     
41     const PHOTOCOUNT = 'fphotoset.PHOTOCOUNT';
42
43     
44     const CREATED_AT = 'fphotoset.CREATED_AT';
45
46     
47     const UPDATED_AT = 'fphotoset.UPDATED_AT';
48
49     
50     private static $phpNameMap = null;
51
52
53     
54     private static $fieldNames = array (
55         BasePeer::TYPE_PHPNAME => array ('Id', 'Flickrid', 'ContentDate', 'Url', 'Title', 'Description', 'Photocount', 'CreatedAt', 'UpdatedAt', ),
56         BasePeer::TYPE_COLNAME => array (FphotosetPeer::ID, FphotosetPeer::FLICKRID, FphotosetPeer::CONTENT_DATE, FphotosetPeer::URL, FphotosetPeer::TITLE, FphotosetPeer::DESCRIPTION, FphotosetPeer::PHOTOCOUNT, FphotosetPeer::CREATED_AT, FphotosetPeer::UPDATED_AT, ),
57         BasePeer::TYPE_FIELDNAME => array ('id', 'flickrid', 'content_date', 'url', 'title', 'description', 'photocount', 'created_at', 'updated_at', ),
58         BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
59     );
60
61     
62     private static $fieldKeys = array (
63         BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Flickrid' => 1, 'ContentDate' => 2, 'Url' => 3, 'Title' => 4, 'Description' => 5, 'Photocount' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ),
64         BasePeer::TYPE_COLNAME => array (FphotosetPeer::ID => 0, FphotosetPeer::FLICKRID => 1, FphotosetPeer::CONTENT_DATE => 2, FphotosetPeer::URL => 3, FphotosetPeer::TITLE => 4, FphotosetPeer::DESCRIPTION => 5, FphotosetPeer::PHOTOCOUNT => 6, FphotosetPeer::CREATED_AT => 7, FphotosetPeer::UPDATED_AT => 8, ),
65         BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'flickrid' => 1, 'content_date' => 2, 'url' => 3, 'title' => 4, 'description' => 5, 'photocount' => 6, 'created_at' => 7, 'updated_at' => 8, ),
66         BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
67     );
68
69     
70     public static function getMapBuilder()
71     {
72         include_once 'plugins/sfFlickrGallery/lib/model/map/FphotosetMapBuilder.php';
73         return BasePeer::getMapBuilder('plugins.sfFlickrGallery.lib.model.map.FphotosetMapBuilder');
74     }
75     
76     public static function getPhpNameMap()
77     {
78         if (self::$phpNameMap === null) {
79             $map = FphotosetPeer::getTableMap();
80             $columns = $map->getColumns();
81             $nameMap = array();
82             foreach ($columns as $column) {
83                 $nameMap[$column->getPhpName()] = $column->getColumnName();
84             }
85             self::$phpNameMap = $nameMap;
86         }
87         return self::$phpNameMap;
88     }
89     
90     static public function translateFieldName($name, $fromType, $toType)
91     {
92         $toNames = self::getFieldNames($toType);
93         $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
94         if ($key === null) {
95             throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
96         }
97         return $toNames[$key];
98     }
99
100     
101
102     static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
103     {
104         if (!array_key_exists($type, self::$fieldNames)) {
105             throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
106         }
107         return self::$fieldNames[$type];
108     }
109
110     
111     public static function alias($alias, $column)
112     {
113         return str_replace(FphotosetPeer::TABLE_NAME.'.', $alias.'.', $column);
114     }
115
116     
117     public static function addSelectColumns(Criteria $criteria)
118     {
119
120         $criteria->addSelectColumn(FphotosetPeer::ID);
121
122         $criteria->addSelectColumn(FphotosetPeer::FLICKRID);
123
124         $criteria->addSelectColumn(FphotosetPeer::CONTENT_DATE);
125
126         $criteria->addSelectColumn(FphotosetPeer::URL);
127
128         $criteria->addSelectColumn(FphotosetPeer::TITLE);
129
130         $criteria->addSelectColumn(FphotosetPeer::DESCRIPTION);
131
132         $criteria->addSelectColumn(FphotosetPeer::PHOTOCOUNT);
133
134         $criteria->addSelectColumn(FphotosetPeer::CREATED_AT);
135
136         $criteria->addSelectColumn(FphotosetPeer::UPDATED_AT);
137
138     }
139
140     const COUNT = 'COUNT(fphotoset.ID)';
141     const COUNT_DISTINCT = 'COUNT(DISTINCT fphotoset.ID)';
142
143     
144     public static function doCount(Criteria $criteria, $distinct = false, $con = null)
145     {
146                 $criteria = clone $criteria;
147
148                 $criteria->clearSelectColumns()->clearOrderByColumns();
149         if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
150             $criteria->addSelectColumn(FphotosetPeer::COUNT_DISTINCT);
151         } else {
152             $criteria->addSelectColumn(FphotosetPeer::COUNT);
153         }
154
155                 foreach($criteria->getGroupByColumns() as $column)
156         {
157             $criteria->addSelectColumn($column);
158         }
159
160         $rs = FphotosetPeer::doSelectRS($criteria, $con);
161         if ($rs->next()) {
162             return $rs->getInt(1);
163         } else {
164                         return 0;
165         }
166     }
167     
168     public static function doSelectOne(Criteria $criteria, $con = null)
169     {
170         $critcopy = clone $criteria;
171         $critcopy->setLimit(1);
172         $objects = FphotosetPeer::doSelect($critcopy, $con);
173         if ($objects) {
174             return $objects[0];
175         }
176         return null;
177     }
178     
179     public static function doSelect(Criteria $criteria, $con = null)
180     {
181         return FphotosetPeer::populateObjects(FphotosetPeer::doSelectRS($criteria, $con));
182     }
183     
184     public static function doSelectRS(Criteria $criteria, $con = null)
185     {
186         if ($con === null) {
187             $con = Propel::getConnection(self::DATABASE_NAME);
188         }
189
190         if (!$criteria->getSelectColumns()) {
191             $criteria = clone $criteria;
192             FphotosetPeer::addSelectColumns($criteria);
193         }
194
195                 $criteria->setDbName(self::DATABASE_NAME);
196
197                         return BasePeer::doSelect($criteria, $con);
198     }
199     
200     public static function populateObjects(ResultSet $rs)
201     {
202         $results = array();
203     
204                 $cls = FphotosetPeer::getOMClass();
205         $cls = Propel::import($cls);
206                 while($rs->next()) {
207         
208             $obj = new $cls();
209             $obj->hydrate($rs);
210             $results[] = $obj;
211             
212         }
213         return $results;
214     }
215     
216     public static function getTableMap()
217     {
218         return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
219     }
220
221     
222     public static function getOMClass()
223     {
224         return FphotosetPeer::CLASS_DEFAULT;
225     }
226
227     
228     public static function doInsert($values, $con = null)
229     {
230         if ($con === null) {
231             $con = Propel::getConnection(self::DATABASE_NAME);
232         }
233
234         if ($values instanceof Criteria) {
235             $criteria = clone $values;         } else {
236             $criteria = $values->buildCriteria();         }
237
238         $criteria->remove(FphotosetPeer::ID);
239
240                 $criteria->setDbName(self::DATABASE_NAME);
241
242         try {
243                                     $con->begin();
244             $pk = BasePeer::doInsert($criteria, $con);
245             $con->commit();
246         } catch(PropelException $e) {
247             $con->rollback();
248             throw $e;
249         }
250
251         return $pk;
252     }
253
254     
255     public static function doUpdate($values, $con = null)
256     {
257         if ($con === null) {
258             $con = Propel::getConnection(self::DATABASE_NAME);
259         }
260
261         $selectCriteria = new Criteria(self::DATABASE_NAME);
262
263         if ($values instanceof Criteria) {
264             $criteria = clone $values;
265             $comparison = $criteria->getComparison(FphotosetPeer::ID);
266             $selectCriteria->add(FphotosetPeer::ID, $criteria->remove(FphotosetPeer::ID), $comparison);
267
268         } else {             $criteria = $values->buildCriteria();             $selectCriteria = $values->buildPkeyCriteria();         }
269
270                 $criteria->setDbName(self::DATABASE_NAME);
271
272         return BasePeer::doUpdate($selectCriteria, $criteria, $con);
273     }
274
275     
276     public static function doDeleteAll($con = null)
277     {
278         if ($con === null) {
279             $con = Propel::getConnection(self::DATABASE_NAME);
280         }
281         $affectedRows = 0;         try {
282                                     $con->begin();
283             $affectedRows += BasePeer::doDeleteAll(FphotosetPeer::TABLE_NAME, $con);
284             $con->commit();
285             return $affectedRows;
286         } catch (PropelException $e) {
287             $con->rollback();
288             throw $e;
289         }
290     }
291
292     
293      public static function doDelete($values, $con = null)
294      {
295         if ($con === null) {
296             $con = Propel::getConnection(FphotosetPeer::DATABASE_NAME);
297         }
298
299         if ($values instanceof Criteria) {
300             $criteria = clone $values;         } elseif ($values instanceof Fphotoset) {
301
302             $criteria = $values->buildPkeyCriteria();
303         } else {
304                         $criteria = new Criteria(self::DATABASE_NAME);
305             $criteria->add(FphotosetPeer::ID, (array) $values, Criteria::IN);
306         }
307
308                 $criteria->setDbName(self::DATABASE_NAME);
309
310         $affectedRows = 0;
311         try {
312                                     $con->begin();
313             
314             $affectedRows += BasePeer::doDelete($criteria, $con);
315             $con->commit();
316             return $affectedRows;
317         } catch (PropelException $e) {
318             $con->rollback();
319             throw $e;
320         }
321     }
322
323     
324     public static function doValidate(Fphotoset $obj, $cols = null)
325     {
326         $columns = array();
327
328         if ($cols) {
329             $dbMap = Propel::getDatabaseMap(FphotosetPeer::DATABASE_NAME);
330             $tableMap = $dbMap->getTable(FphotosetPeer::TABLE_NAME);
331
332             if (! is_array($cols)) {
333                 $cols = array($cols);
334             }
335
336             foreach($cols as $colName) {
337                 if ($tableMap->containsColumn($colName)) {
338                     $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
339                     $columns[$colName] = $obj->$get();
340                 }
341             }
342         } else {
343
344         }
345
346         $res BasePeer::doValidate(FphotosetPeer::DATABASE_NAME, FphotosetPeer::TABLE_NAME, $columns);
347     if ($res !== true) {
348         $request = sfContext::getInstance()->getRequest();
349         foreach ($res as $failed) {
350             $col = FphotosetPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
351             $request->setError($col, $failed->getMessage());
352         }
353     }
354
355     return $res;
356     }
357
358     
359     public static function retrieveByPK($pk, $con = null)
360     {
361         if ($con === null) {
362             $con = Propel::getConnection(self::DATABASE_NAME);
363         }
364
365         $criteria = new Criteria(FphotosetPeer::DATABASE_NAME);
366
367         $criteria->add(FphotosetPeer::ID, $pk);
368
369
370         $v = FphotosetPeer::doSelect($criteria, $con);
371
372         return !empty($v) > 0 ? $v[0] : null;
373     }
374
375     
376     public static function retrieveByPKs($pks, $con = null)
377     {
378         if ($con === null) {
379             $con = Propel::getConnection(self::DATABASE_NAME);
380         }
381
382         $objs = null;
383         if (empty($pks)) {
384             $objs = array();
385         } else {
386             $criteria = new Criteria();
387             $criteria->add(FphotosetPeer::ID, $pks, Criteria::IN);
388             $objs = FphotosetPeer::doSelect($criteria, $con);
389         }
390         return $objs;
391     }
392
393 }
394 if (Propel::isInit()) {
395             try {
396         BaseFphotosetPeer::getMapBuilder();
397     } catch (Exception $e) {
398         Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
399     }
400 } else {
401             require_once 'plugins/sfFlickrGallery/lib/model/map/FphotosetMapBuilder.php';
402     Propel::registerMapBuilder('plugins.sfFlickrGallery.lib.model.map.FphotosetMapBuilder');
403 }
404
Note: See TracBrowser for help on using the browser.