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

Source for file BaseEtvaNodePeer.php

Documentation is available at BaseEtvaNodePeer.php

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

Documentation generated on Fri, 19 Jun 2009 10:47:26 +0100 by phpDocumentor 1.4.2