5 * Base static class for performing query and update operations on the 'werkzeug' table.
9 * @package propel.generator.propel.om
11 abstract class BaseWerkzeugPeer
14 /** the default database name for this class */
15 const DATABASE_NAME = 'mkrimi';
17 /** the table name for this class */
18 const TABLE_NAME = 'werkzeug';
20 /** the related Propel class for this table */
21 const OM_CLASS = 'Werkzeug';
23 /** the related TableMap class for this table */
24 const TM_CLASS = 'WerkzeugTableMap';
26 /** The total number of columns. */
27 const NUM_COLUMNS = 6;
29 /** The number of lazy-loaded columns. */
30 const NUM_LAZY_LOAD_COLUMNS = 0;
32 /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */
33 const NUM_HYDRATE_COLUMNS = 6;
35 /** the column name for the id field */
36 const ID = 'werkzeug.id';
38 /** the column name for the mod field */
39 const MOD = 'werkzeug.mod';
41 /** the column name for the typ field */
42 const TYP = 'werkzeug.typ';
44 /** the column name for the beschreibung field */
45 const BESCHREIBUNG = 'werkzeug.beschreibung';
47 /** the column name for the eigentumer field */
48 const EIGENTUMER = 'werkzeug.eigentumer';
50 /** the column name for the zz_bei field */
51 const ZZ_BEI = 'werkzeug.zz_bei';
53 /** The default string format for model objects of the related table **/
54 const DEFAULT_STRING_FORMAT = 'YAML';
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
60 * @var array Werkzeug[]
62 public static $instances = array();
66 * holds an array of fieldnames
68 * first dimension keys are the type constants
69 * e.g. WerkzeugPeer::$fieldNames[WerkzeugPeer::TYPE_PHPNAME][0] = 'Id'
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, )
81 * holds an array of keys for quick access to the fieldnames array
83 * first dimension keys are the type constants
84 * e.g. WerkzeugPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
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, )
96 * Translates a fieldname to another type
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.
105 public static function translateFieldName($name, $fromType, $toType)
107 $toNames = WerkzeugPeer::getFieldNames($toType);
108 $key = isset(WerkzeugPeer::$fieldKeys[$fromType][$name]) ? WerkzeugPeer::$fieldKeys[$fromType][$name] : 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));
113 return $toNames[$key];
117 * Returns an array of field names.
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.
125 public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
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.');
131 return WerkzeugPeer::$fieldNames[$type];
135 * Convenience method which changes table.column to alias.column.
137 * Using this method you can maintain SQL abstraction while using column aliases.
139 * $c->addAlias("alias1", TablePeer::TABLE_NAME);
140 * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
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).
146 public static function alias($alias, $column)
148 return str_replace(WerkzeugPeer::TABLE_NAME.'.', $alias.'.', $column);
152 * Add all the columns needed to create a new object.
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
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.
163 public static function addSelectColumns(Criteria $criteria, $alias = null)
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);
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');
183 * Returns the number of rows matching criteria.
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.
190 public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
192 // we may modify criteria, so copy it first
193 $criteria = clone $criteria;
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);
200 if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
201 $criteria->setDistinct();
204 if (!$criteria->hasSelectClause()) {
205 WerkzeugPeer::addSelectColumns($criteria);
208 $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
209 $criteria->setDbName(WerkzeugPeer::DATABASE_NAME); // Set the correct dbName
212 $con = Propel::getConnection(WerkzeugPeer::DATABASE_NAME, Propel::CONNECTION_READ);
214 // BasePeer returns a PDOStatement
215 $stmt = BasePeer::doCount($criteria, $con);
217 if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
218 $count = (int) $row[0];
220 $count = 0; // no rows returned; we infer that means 0 matches.
222 $stmt->closeCursor();
227 * Selects one object from the DB.
229 * @param Criteria $criteria object used to create the SELECT statement.
230 * @param PropelPDO $con
232 * @throws PropelException Any exceptions caught during processing will be
233 * rethrown wrapped into a PropelException.
235 public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
237 $critcopy = clone $criteria;
238 $critcopy->setLimit(1);
239 $objects = WerkzeugPeer::doSelect($critcopy, $con);
247 * Selects several row from the DB.
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.
255 public static function doSelect(Criteria $criteria, PropelPDO $con = null)
257 return WerkzeugPeer::populateObjects(WerkzeugPeer::doSelectStmt($criteria, $con));
260 * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
262 * Use this method directly if you want to work with an executed statement directly (for example
263 * to perform your own object hydration).
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()
272 public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
275 $con = Propel::getConnection(WerkzeugPeer::DATABASE_NAME, Propel::CONNECTION_READ);
278 if (!$criteria->hasSelectClause()) {
279 $criteria = clone $criteria;
280 WerkzeugPeer::addSelectColumns($criteria);
283 // Set the correct dbName
284 $criteria->setDbName(WerkzeugPeer::DATABASE_NAME);
286 // BasePeer returns a PDOStatement
287 return BasePeer::doSelect($criteria, $con);
290 * Adds an object to the instance pool.
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.
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).
301 public static function addInstanceToPool($obj, $key = null)
303 if (Propel::isInstancePoolingEnabled()) {
305 $key = (string) $obj->getId();
307 WerkzeugPeer::$instances[$key] = $obj;
312 * Removes an object from the instance pool.
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.
319 * @param mixed $value A Werkzeug object or a primary key value.
322 * @throws PropelException - if the value is invalid.
324 public static function removeInstanceFromPool($value)
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;
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)));
337 unset(WerkzeugPeer::$instances[$key]);
339 } // removeInstanceFromPool()
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.
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.
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()
351 public static function getInstanceFromPool($key)
353 if (Propel::isInstancePoolingEnabled()) {
354 if (isset(WerkzeugPeer::$instances[$key])) {
355 return WerkzeugPeer::$instances[$key];
359 return null; // just to be explicit
363 * Clear the instance pool.
367 public static function clearInstancePool($and_clear_all_references = false)
369 if ($and_clear_all_references) {
370 foreach (WerkzeugPeer::$instances as $instance) {
371 $instance->clearAllReferences(true);
374 WerkzeugPeer::$instances = array();
378 * Method to invalidate the instance pool of all tables related to werkzeug
379 * by a foreign key with ON DELETE CASCADE
381 public static function clearRelatedInstancePool()
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.
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.
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.
395 public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
397 // If the PK cannot be derived from the row, return null.
398 if ($row[$startcol] === null) {
402 return (string) $row[$startcol];
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.
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
414 public static function getPrimaryKeyFromRow($row, $startcol = 0)
417 return (int) $row[$startcol];
421 * The returned array will contain objects of the default type or
422 * objects that inherit from the default.
424 * @throws PropelException Any exceptions caught during processing will be
425 * rethrown wrapped into a PropelException.
427 public static function populateObjects(PDOStatement $stmt)
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
445 WerkzeugPeer::addInstanceToPool($obj, $key);
448 $stmt->closeCursor();
453 * Populates an object of the default type or an object that inherit from the default.
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)
461 public static function populateObject($row, $startcol = 0)
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;
470 $cls = WerkzeugPeer::OM_CLASS;
472 $col = $obj->hydrate($row, $startcol);
473 WerkzeugPeer::addInstanceToPool($obj, $key);
476 return array($obj, $col);
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.
483 * @throws PropelException Any exceptions caught during processing will be
484 * rethrown wrapped into a PropelException.
486 public static function getTableMap()
488 return Propel::getDatabaseMap(WerkzeugPeer::DATABASE_NAME)->getTable(WerkzeugPeer::TABLE_NAME);
492 * Add a TableMap instance to the database for this peer class.
494 public static function buildTableMap()
496 $dbMap = Propel::getDatabaseMap(BaseWerkzeugPeer::DATABASE_NAME);
497 if (!$dbMap->hasTable(BaseWerkzeugPeer::TABLE_NAME)) {
498 $dbMap->addTableObject(new \WerkzeugTableMap());
503 * The class that the Peer will make instances of.
506 * @return string ClassName
508 public static function getOMClass($row = 0, $colnum = 0)
510 return WerkzeugPeer::OM_CLASS;
514 * Performs an INSERT on the database, given a Werkzeug or Criteria object.
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.
522 public static function doInsert($values, PropelPDO $con = null)
525 $con = Propel::getConnection(WerkzeugPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
528 if ($values instanceof Criteria) {
529 $criteria = clone $values; // rename for clarity
531 $criteria = $values->buildCriteria(); // build Criteria from Werkzeug object
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.')');
539 // Set the correct dbName
540 $criteria->setDbName(WerkzeugPeer::DATABASE_NAME);
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);
548 } catch (Exception $e) {
557 * Performs an UPDATE on the database, given a Werkzeug or Criteria object.
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.
565 public static function doUpdate($values, PropelPDO $con = null)
568 $con = Propel::getConnection(WerkzeugPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
571 $selectCriteria = new Criteria(WerkzeugPeer::DATABASE_NAME);
573 if ($values instanceof Criteria) {
574 $criteria = clone $values; // rename for clarity
576 $comparison = $criteria->getComparison(WerkzeugPeer::ID);
577 $value = $criteria->remove(WerkzeugPeer::ID);
579 $selectCriteria->add(WerkzeugPeer::ID, $value, $comparison);
581 $selectCriteria->setPrimaryTableName(WerkzeugPeer::TABLE_NAME);
584 } else { // $values is Werkzeug object
585 $criteria = $values->buildCriteria(); // gets full criteria
586 $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
589 // set the correct dbName
590 $criteria->setDbName(WerkzeugPeer::DATABASE_NAME);
592 return BasePeer::doUpdate($selectCriteria, $criteria, $con);
596 * Deletes all rows from the werkzeug table.
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
602 public static function doDeleteAll(PropelPDO $con = null)
605 $con = Propel::getConnection(WerkzeugPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
607 $affectedRows = 0; // initialize var to track total num of affected rows
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();
620 return $affectedRows;
621 } catch (Exception $e) {
628 * Performs a DELETE on the database, given a Werkzeug or Criteria object OR a primary key value.
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.
638 public static function doDelete($values, PropelPDO $con = null)
641 $con = Propel::getConnection(WerkzeugPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
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);
665 // Set the correct dbName
666 $criteria->setDbName(WerkzeugPeer::DATABASE_NAME);
668 $affectedRows = 0; // initialize var to track total num of affected rows
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();
675 $affectedRows += BasePeer::doDelete($criteria, $con);
676 WerkzeugPeer::clearRelatedInstancePool();
679 return $affectedRows;
680 } catch (Exception $e) {
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.
691 * NOTICE: This does not apply to primary or foreign keys for now.
693 * @param Werkzeug $obj The object to validate.
694 * @param mixed $cols Column name or array of column names.
696 * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
698 public static function doValidate($obj, $cols = null)
703 $dbMap = Propel::getDatabaseMap(WerkzeugPeer::DATABASE_NAME);
704 $tableMap = $dbMap->getTable(WerkzeugPeer::TABLE_NAME);
706 if (! is_array($cols)) {
707 $cols = array($cols);
710 foreach ($cols as $colName) {
711 if ($tableMap->hasColumn($colName)) {
712 $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
713 $columns[$colName] = $obj->$get();
720 return BasePeer::doValidate(WerkzeugPeer::DATABASE_NAME, WerkzeugPeer::TABLE_NAME, $columns);
724 * Retrieve a single object by pkey.
726 * @param int $pk the primary key.
727 * @param PropelPDO $con the connection to use
730 public static function retrieveByPK($pk, PropelPDO $con = null)
733 if (null !== ($obj = WerkzeugPeer::getInstanceFromPool((string) $pk))) {
738 $con = Propel::getConnection(WerkzeugPeer::DATABASE_NAME, Propel::CONNECTION_READ);
741 $criteria = new Criteria(WerkzeugPeer::DATABASE_NAME);
742 $criteria->add(WerkzeugPeer::ID, $pk);
744 $v = WerkzeugPeer::doSelect($criteria, $con);
746 return !empty($v) > 0 ? $v[0] : null;
750 * Retrieve multiple objects by pkey.
752 * @param array $pks List of primary keys
753 * @param PropelPDO $con the connection to use
755 * @throws PropelException Any exceptions caught during processing will be
756 * rethrown wrapped into a PropelException.
758 public static function retrieveByPKs($pks, PropelPDO $con = null)
761 $con = Propel::getConnection(WerkzeugPeer::DATABASE_NAME, Propel::CONNECTION_READ);
768 $criteria = new Criteria(WerkzeugPeer::DATABASE_NAME);
769 $criteria->add(WerkzeugPeer::ID, $pks, Criteria::IN);
770 $objs = WerkzeugPeer::doSelect($criteria, $con);
776 } // BaseWerkzeugPeer
778 // This is the static code needed to register the TableMap for this table with the main Propel class.
780 BaseWerkzeugPeer::buildTableMap();