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