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