lib-model-om
[ class tree: lib-model-om ] [ index: lib-model-om ] [ all elements ]

Source for file BaseEtvaMacPeer.php

Documentation is available at BaseEtvaMacPeer.php

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

Documentation generated on Fri, 19 Jun 2009 10:46:45 +0100 by phpDocumentor 1.4.2