1 | <?php |
---|
2 | |
---|
3 | |
---|
4 | abstract class BaseTblspacecategoryPeer { |
---|
5 | |
---|
6 | |
---|
7 | const DATABASE_NAME = 'propel'; |
---|
8 | |
---|
9 | |
---|
10 | const TABLE_NAME = 'tblspacecategory'; |
---|
11 | |
---|
12 | |
---|
13 | const CLASS_DEFAULT = 'lib.model.Tblspacecategory'; |
---|
14 | |
---|
15 | |
---|
16 | const NUM_COLUMNS = 5; |
---|
17 | |
---|
18 | |
---|
19 | const NUM_LAZY_LOAD_COLUMNS = 0; |
---|
20 | |
---|
21 | |
---|
22 | const CAT_ID = 'tblspacecategory.CAT_ID'; |
---|
23 | |
---|
24 | |
---|
25 | const CAT_NAME = 'tblspacecategory.CAT_NAME'; |
---|
26 | |
---|
27 | |
---|
28 | const CAT_PARENT = 'tblspacecategory.CAT_PARENT'; |
---|
29 | |
---|
30 | |
---|
31 | const CAT_USER = 'tblspacecategory.CAT_USER'; |
---|
32 | |
---|
33 | |
---|
34 | const CAT_DATE = 'tblspacecategory.CAT_DATE'; |
---|
35 | |
---|
36 | |
---|
37 | public static $instances = array(); |
---|
38 | |
---|
39 | |
---|
40 | private static $mapBuilder = null; |
---|
41 | |
---|
42 | |
---|
43 | private static $fieldNames = array ( |
---|
44 | BasePeer::TYPE_PHPNAME => array ('CatId', 'CatName', 'CatParent', 'CatUser', 'CatDate', ), |
---|
45 | BasePeer::TYPE_STUDLYPHPNAME => array ('catId', 'catName', 'catParent', 'catUser', 'catDate', ), |
---|
46 | BasePeer::TYPE_COLNAME => array (self::CAT_ID, self::CAT_NAME, self::CAT_PARENT, self::CAT_USER, self::CAT_DATE, ), |
---|
47 | BasePeer::TYPE_FIELDNAME => array ('cat_id', 'cat_name', 'cat_parent', 'cat_user', 'cat_date', ), |
---|
48 | BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) |
---|
49 | ); |
---|
50 | |
---|
51 | |
---|
52 | private static $fieldKeys = array ( |
---|
53 | BasePeer::TYPE_PHPNAME => array ('CatId' => 0, 'CatName' => 1, 'CatParent' => 2, 'CatUser' => 3, 'CatDate' => 4, ), |
---|
54 | BasePeer::TYPE_STUDLYPHPNAME => array ('catId' => 0, 'catName' => 1, 'catParent' => 2, 'catUser' => 3, 'catDate' => 4, ), |
---|
55 | BasePeer::TYPE_COLNAME => array (self::CAT_ID => 0, self::CAT_NAME => 1, self::CAT_PARENT => 2, self::CAT_USER => 3, self::CAT_DATE => 4, ), |
---|
56 | BasePeer::TYPE_FIELDNAME => array ('cat_id' => 0, 'cat_name' => 1, 'cat_parent' => 2, 'cat_user' => 3, 'cat_date' => 4, ), |
---|
57 | BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) |
---|
58 | ); |
---|
59 | |
---|
60 | |
---|
61 | public static function getMapBuilder() |
---|
62 | { |
---|
63 | if (self::$mapBuilder === null) { |
---|
64 | self::$mapBuilder = new TblspacecategoryMapBuilder(); |
---|
65 | } |
---|
66 | return self::$mapBuilder; |
---|
67 | } |
---|
68 | |
---|
69 | static public function translateFieldName($name, $fromType, $toType) |
---|
70 | { |
---|
71 | $toNames = self::getFieldNames($toType); |
---|
72 | $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; |
---|
73 | if ($key === null) { |
---|
74 | throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); |
---|
75 | } |
---|
76 | return $toNames[$key]; |
---|
77 | } |
---|
78 | |
---|
79 | |
---|
80 | |
---|
81 | static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) |
---|
82 | { |
---|
83 | if (!array_key_exists($type, self::$fieldNames)) { |
---|
84 | 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.'); |
---|
85 | } |
---|
86 | return self::$fieldNames[$type]; |
---|
87 | } |
---|
88 | |
---|
89 | |
---|
90 | public static function alias($alias, $column) |
---|
91 | { |
---|
92 | return str_replace(TblspacecategoryPeer::TABLE_NAME.'.', $alias.'.', $column); |
---|
93 | } |
---|
94 | |
---|
95 | |
---|
96 | public static function addSelectColumns(Criteria $criteria) |
---|
97 | { |
---|
98 | |
---|
99 | $criteria->addSelectColumn(TblspacecategoryPeer::CAT_ID); |
---|
100 | |
---|
101 | $criteria->addSelectColumn(TblspacecategoryPeer::CAT_NAME); |
---|
102 | |
---|
103 | $criteria->addSelectColumn(TblspacecategoryPeer::CAT_PARENT); |
---|
104 | |
---|
105 | $criteria->addSelectColumn(TblspacecategoryPeer::CAT_USER); |
---|
106 | |
---|
107 | $criteria->addSelectColumn(TblspacecategoryPeer::CAT_DATE); |
---|
108 | |
---|
109 | } |
---|
110 | |
---|
111 | |
---|
112 | public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) |
---|
113 | { |
---|
114 | $criteria = clone $criteria; |
---|
115 | |
---|
116 | $criteria->setPrimaryTableName(TblspacecategoryPeer::TABLE_NAME); |
---|
117 | |
---|
118 | if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { |
---|
119 | $criteria->setDistinct(); |
---|
120 | } |
---|
121 | |
---|
122 | if (!$criteria->hasSelectClause()) { |
---|
123 | TblspacecategoryPeer::addSelectColumns($criteria); |
---|
124 | } |
---|
125 | |
---|
126 | $criteria->clearOrderByColumns(); $criteria->setDbName(self::DATABASE_NAME); |
---|
127 | if ($con === null) { |
---|
128 | $con = Propel::getConnection(TblspacecategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); |
---|
129 | } |
---|
130 | $stmt = BasePeer::doCount($criteria, $con); |
---|
131 | |
---|
132 | if ($row = $stmt->fetch(PDO::FETCH_NUM)) { |
---|
133 | $count = (int) $row[0]; |
---|
134 | } else { |
---|
135 | $count = 0; } |
---|
136 | $stmt->closeCursor(); |
---|
137 | return $count; |
---|
138 | } |
---|
139 | |
---|
140 | public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) |
---|
141 | { |
---|
142 | $critcopy = clone $criteria; |
---|
143 | $critcopy->setLimit(1); |
---|
144 | $objects = TblspacecategoryPeer::doSelect($critcopy, $con); |
---|
145 | if ($objects) { |
---|
146 | return $objects[0]; |
---|
147 | } |
---|
148 | return null; |
---|
149 | } |
---|
150 | |
---|
151 | public static function doSelect(Criteria $criteria, PropelPDO $con = null) |
---|
152 | { |
---|
153 | return TblspacecategoryPeer::populateObjects(TblspacecategoryPeer::doSelectStmt($criteria, $con)); |
---|
154 | } |
---|
155 | |
---|
156 | public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) |
---|
157 | { |
---|
158 | if ($con === null) { |
---|
159 | $con = Propel::getConnection(TblspacecategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); |
---|
160 | } |
---|
161 | |
---|
162 | if (!$criteria->hasSelectClause()) { |
---|
163 | $criteria = clone $criteria; |
---|
164 | TblspacecategoryPeer::addSelectColumns($criteria); |
---|
165 | } |
---|
166 | |
---|
167 | $criteria->setDbName(self::DATABASE_NAME); |
---|
168 | |
---|
169 | return BasePeer::doSelect($criteria, $con); |
---|
170 | } |
---|
171 | |
---|
172 | public static function addInstanceToPool(Tblspacecategory $obj, $key = null) |
---|
173 | { |
---|
174 | if (Propel::isInstancePoolingEnabled()) { |
---|
175 | if ($key === null) { |
---|
176 | $key = (string) $obj->getCatId(); |
---|
177 | } self::$instances[$key] = $obj; |
---|
178 | } |
---|
179 | } |
---|
180 | |
---|
181 | |
---|
182 | public static function removeInstanceFromPool($value) |
---|
183 | { |
---|
184 | if (Propel::isInstancePoolingEnabled() && $value !== null) { |
---|
185 | if (is_object($value) && $value instanceof Tblspacecategory) { |
---|
186 | $key = (string) $value->getCatId(); |
---|
187 | } elseif (is_scalar($value)) { |
---|
188 | $key = (string) $value; |
---|
189 | } else { |
---|
190 | $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Tblspacecategory object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); |
---|
191 | throw $e; |
---|
192 | } |
---|
193 | |
---|
194 | unset(self::$instances[$key]); |
---|
195 | } |
---|
196 | } |
---|
197 | |
---|
198 | public static function getInstanceFromPool($key) |
---|
199 | { |
---|
200 | if (Propel::isInstancePoolingEnabled()) { |
---|
201 | if (isset(self::$instances[$key])) { |
---|
202 | return self::$instances[$key]; |
---|
203 | } |
---|
204 | } |
---|
205 | return null; } |
---|
206 | |
---|
207 | |
---|
208 | public static function clearInstancePool() |
---|
209 | { |
---|
210 | self::$instances = array(); |
---|
211 | } |
---|
212 | |
---|
213 | |
---|
214 | public static function getPrimaryKeyHashFromRow($row, $startcol = 0) |
---|
215 | { |
---|
216 | if ($row[$startcol + 0] === null) { |
---|
217 | return null; |
---|
218 | } |
---|
219 | return (string) $row[$startcol + 0]; |
---|
220 | } |
---|
221 | |
---|
222 | |
---|
223 | public static function populateObjects(PDOStatement $stmt) |
---|
224 | { |
---|
225 | $results = array(); |
---|
226 | |
---|
227 | $cls = TblspacecategoryPeer::getOMClass(); |
---|
228 | $cls = substr('.'.$cls, strrpos('.'.$cls, '.') + 1); |
---|
229 | while ($row = $stmt->fetch(PDO::FETCH_NUM)) { |
---|
230 | $key = TblspacecategoryPeer::getPrimaryKeyHashFromRow($row, 0); |
---|
231 | if (null !== ($obj = TblspacecategoryPeer::getInstanceFromPool($key))) { |
---|
232 | $results[] = $obj; |
---|
233 | } else { |
---|
234 | |
---|
235 | $obj = new $cls(); |
---|
236 | $obj->hydrate($row); |
---|
237 | $results[] = $obj; |
---|
238 | TblspacecategoryPeer::addInstanceToPool($obj, $key); |
---|
239 | } } |
---|
240 | $stmt->closeCursor(); |
---|
241 | return $results; |
---|
242 | } |
---|
243 | |
---|
244 | public static function getTableMap() |
---|
245 | { |
---|
246 | return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); |
---|
247 | } |
---|
248 | |
---|
249 | |
---|
250 | public static function getOMClass() |
---|
251 | { |
---|
252 | return TblspacecategoryPeer::CLASS_DEFAULT; |
---|
253 | } |
---|
254 | |
---|
255 | |
---|
256 | public static function doInsert($values, PropelPDO $con = null) |
---|
257 | { |
---|
258 | if ($con === null) { |
---|
259 | $con = Propel::getConnection(TblspacecategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); |
---|
260 | } |
---|
261 | |
---|
262 | if ($values instanceof Criteria) { |
---|
263 | $criteria = clone $values; } else { |
---|
264 | $criteria = $values->buildCriteria(); } |
---|
265 | |
---|
266 | if ($criteria->containsKey(TblspacecategoryPeer::CAT_ID) && $criteria->keyContainsValue(TblspacecategoryPeer::CAT_ID) ) { |
---|
267 | throw new PropelException('Cannot insert a value for auto-increment primary key ('.TblspacecategoryPeer::CAT_ID.')'); |
---|
268 | } |
---|
269 | |
---|
270 | |
---|
271 | $criteria->setDbName(self::DATABASE_NAME); |
---|
272 | |
---|
273 | try { |
---|
274 | $con->beginTransaction(); |
---|
275 | $pk = BasePeer::doInsert($criteria, $con); |
---|
276 | $con->commit(); |
---|
277 | } catch(PropelException $e) { |
---|
278 | $con->rollBack(); |
---|
279 | throw $e; |
---|
280 | } |
---|
281 | |
---|
282 | return $pk; |
---|
283 | } |
---|
284 | |
---|
285 | |
---|
286 | public static function doUpdate($values, PropelPDO $con = null) |
---|
287 | { |
---|
288 | if ($con === null) { |
---|
289 | $con = Propel::getConnection(TblspacecategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); |
---|
290 | } |
---|
291 | |
---|
292 | $selectCriteria = new Criteria(self::DATABASE_NAME); |
---|
293 | |
---|
294 | if ($values instanceof Criteria) { |
---|
295 | $criteria = clone $values; |
---|
296 | $comparison = $criteria->getComparison(TblspacecategoryPeer::CAT_ID); |
---|
297 | $selectCriteria->add(TblspacecategoryPeer::CAT_ID, $criteria->remove(TblspacecategoryPeer::CAT_ID), $comparison); |
---|
298 | |
---|
299 | } else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); } |
---|
300 | |
---|
301 | $criteria->setDbName(self::DATABASE_NAME); |
---|
302 | |
---|
303 | return BasePeer::doUpdate($selectCriteria, $criteria, $con); |
---|
304 | } |
---|
305 | |
---|
306 | |
---|
307 | public static function doDeleteAll($con = null) |
---|
308 | { |
---|
309 | if ($con === null) { |
---|
310 | $con = Propel::getConnection(TblspacecategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); |
---|
311 | } |
---|
312 | $affectedRows = 0; try { |
---|
313 | $con->beginTransaction(); |
---|
314 | $affectedRows += BasePeer::doDeleteAll(TblspacecategoryPeer::TABLE_NAME, $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 doDelete($values, PropelPDO $con = null) |
---|
325 | { |
---|
326 | if ($con === null) { |
---|
327 | $con = Propel::getConnection(TblspacecategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); |
---|
328 | } |
---|
329 | |
---|
330 | if ($values instanceof Criteria) { |
---|
331 | TblspacecategoryPeer::clearInstancePool(); |
---|
332 | |
---|
333 | $criteria = clone $values; |
---|
334 | } elseif ($values instanceof Tblspacecategory) { |
---|
335 | TblspacecategoryPeer::removeInstanceFromPool($values); |
---|
336 | $criteria = $values->buildPkeyCriteria(); |
---|
337 | } else { |
---|
338 | |
---|
339 | |
---|
340 | |
---|
341 | $criteria = new Criteria(self::DATABASE_NAME); |
---|
342 | $criteria->add(TblspacecategoryPeer::CAT_ID, (array) $values, Criteria::IN); |
---|
343 | |
---|
344 | foreach ((array) $values as $singleval) { |
---|
345 | TblspacecategoryPeer::removeInstanceFromPool($singleval); |
---|
346 | } |
---|
347 | } |
---|
348 | |
---|
349 | $criteria->setDbName(self::DATABASE_NAME); |
---|
350 | |
---|
351 | $affectedRows = 0; |
---|
352 | try { |
---|
353 | $con->beginTransaction(); |
---|
354 | |
---|
355 | $affectedRows += BasePeer::doDelete($criteria, $con); |
---|
356 | |
---|
357 | $con->commit(); |
---|
358 | return $affectedRows; |
---|
359 | } catch (PropelException $e) { |
---|
360 | $con->rollBack(); |
---|
361 | throw $e; |
---|
362 | } |
---|
363 | } |
---|
364 | |
---|
365 | |
---|
366 | public static function doValidate(Tblspacecategory $obj, $cols = null) |
---|
367 | { |
---|
368 | $columns = array(); |
---|
369 | |
---|
370 | if ($cols) { |
---|
371 | $dbMap = Propel::getDatabaseMap(TblspacecategoryPeer::DATABASE_NAME); |
---|
372 | $tableMap = $dbMap->getTable(TblspacecategoryPeer::TABLE_NAME); |
---|
373 | |
---|
374 | if (! is_array($cols)) { |
---|
375 | $cols = array($cols); |
---|
376 | } |
---|
377 | |
---|
378 | foreach ($cols as $colName) { |
---|
379 | if ($tableMap->containsColumn($colName)) { |
---|
380 | $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); |
---|
381 | $columns[$colName] = $obj->$get(); |
---|
382 | } |
---|
383 | } |
---|
384 | } else { |
---|
385 | |
---|
386 | } |
---|
387 | |
---|
388 | $res = BasePeer::doValidate(TblspacecategoryPeer::DATABASE_NAME, TblspacecategoryPeer::TABLE_NAME, $columns); |
---|
389 | if ($res !== true) { |
---|
390 | $request = sfContext::getInstance()->getRequest(); |
---|
391 | foreach ($res as $failed) { |
---|
392 | $col = TblspacecategoryPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); |
---|
393 | $request->setError($col, $failed->getMessage()); |
---|
394 | } |
---|
395 | } |
---|
396 | |
---|
397 | return $res; |
---|
398 | } |
---|
399 | |
---|
400 | |
---|
401 | public static function retrieveByPK($pk, PropelPDO $con = null) |
---|
402 | { |
---|
403 | |
---|
404 | if (null !== ($obj = TblspacecategoryPeer::getInstanceFromPool((string) $pk))) { |
---|
405 | return $obj; |
---|
406 | } |
---|
407 | |
---|
408 | if ($con === null) { |
---|
409 | $con = Propel::getConnection(TblspacecategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); |
---|
410 | } |
---|
411 | |
---|
412 | $criteria = new Criteria(TblspacecategoryPeer::DATABASE_NAME); |
---|
413 | $criteria->add(TblspacecategoryPeer::CAT_ID, $pk); |
---|
414 | |
---|
415 | $v = TblspacecategoryPeer::doSelect($criteria, $con); |
---|
416 | |
---|
417 | return !empty($v) > 0 ? $v[0] : null; |
---|
418 | } |
---|
419 | |
---|
420 | |
---|
421 | public static function retrieveByPKs($pks, PropelPDO $con = null) |
---|
422 | { |
---|
423 | if ($con === null) { |
---|
424 | $con = Propel::getConnection(TblspacecategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); |
---|
425 | } |
---|
426 | |
---|
427 | $objs = null; |
---|
428 | if (empty($pks)) { |
---|
429 | $objs = array(); |
---|
430 | } else { |
---|
431 | $criteria = new Criteria(TblspacecategoryPeer::DATABASE_NAME); |
---|
432 | $criteria->add(TblspacecategoryPeer::CAT_ID, $pks, Criteria::IN); |
---|
433 | $objs = TblspacecategoryPeer::doSelect($criteria, $con); |
---|
434 | } |
---|
435 | return $objs; |
---|
436 | } |
---|
437 | |
---|
438 | } |
---|
439 | |
---|
440 | Propel::getDatabaseMap(BaseTblspacecategoryPeer::DATABASE_NAME)->addTableBuilder(BaseTblspacecategoryPeer::TABLE_NAME, BaseTblspacecategoryPeer::getMapBuilder()); |
---|
441 | |
---|