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

Source for file BaseEtvaAgentPeer.php

Documentation is available at BaseEtvaAgentPeer.php

  1. <?php
  2.  
  3. /**
  4.  * Base static class for performing query and update operations on the 'agent' 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 BaseEtvaAgentPeer {
  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 'agent';
  21.  
  22.     /** A class that can be returned by this peer. */
  23.     const CLASS_DEFAULT 'lib.model.EtvaAgent';
  24.  
  25.     /** The total number of columns. */
  26.     const NUM_COLUMNS 9;
  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 'agent.ID';
  33.  
  34.     /** the column name for the SERVER_ID field */
  35.     const SERVER_ID 'agent.SERVER_ID';
  36.  
  37.     /** the column name for the NAME field */
  38.     const NAME 'agent.NAME';
  39.  
  40.     /** the column name for the DESCRIPTION field */
  41.     const DESCRIPTION 'agent.DESCRIPTION';
  42.  
  43.     /** the column name for the SERVICE field */
  44.     const SERVICE 'agent.SERVICE';
  45.  
  46.     /** the column name for the IP field */
  47.     const IP 'agent.IP';
  48.  
  49.     /** the column name for the STATE field */
  50.     const STATE 'agent.STATE';
  51.  
  52.     /** the column name for the CREATED_AT field */
  53.     const CREATED_AT 'agent.CREATED_AT';
  54.  
  55.     /** the column name for the UPDATED_AT field */
  56.     const UPDATED_AT 'agent.UPDATED_AT';
  57.  
  58.     /**
  59.      * An identiy map to hold any loaded instances of EtvaAgent objects.
  60.      * This must be public so that other peer classes can access this when hydrating from JOIN
  61.      * queries.
  62.      * @var        array EtvaAgent[]
  63.      */
  64.     public static $instances array();
  65.  
  66.     /**
  67.      * The MapBuilder instance for this peer.
  68.      * @var        MapBuilder 
  69.      */
  70.     private static $mapBuilder null;
  71.  
  72.     /**
  73.      * holds an array of fieldnames
  74.      *
  75.      * first dimension keys are the type constants
  76.      * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
  77.      */
  78.     private static $fieldNames array (
  79.         BasePeer::TYPE_PHPNAME => array ('Id''ServerId''Name''Description''Service''Ip''State''CreatedAt''UpdatedAt'),
  80.         BasePeer::TYPE_STUDLYPHPNAME => array ('id''serverId''name''description''service''ip''state''createdAt''updatedAt'),
  81.         BasePeer::TYPE_COLNAME => array (self::IDself::SERVER_IDself::NAMEself::DESCRIPTIONself::SERVICEself::IPself::STATEself::CREATED_ATself::UPDATED_AT),
  82.         BasePeer::TYPE_FIELDNAME => array ('id''server_id''name''description''service''ip''state''created_at''updated_at'),
  83.         BasePeer::TYPE_NUM => array (012345678)
  84.     );
  85.  
  86.     /**
  87.      * holds an array of keys for quick access to the fieldnames array
  88.      *
  89.      * first dimension keys are the type constants
  90.      * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
  91.      */
  92.     private static $fieldKeys array (
  93.         BasePeer::TYPE_PHPNAME => array ('Id' => 0'ServerId' => 1'Name' => 2'Description' => 3'Service' => 4'Ip' => 5'State' => 6'CreatedAt' => 7'UpdatedAt' => 8),
  94.         BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0'serverId' => 1'name' => 2'description' => 3'service' => 4'ip' => 5'state' => 6'createdAt' => 7'updatedAt' => 8),
  95.         BasePeer::TYPE_COLNAME => array (self::ID => 0self::SERVER_ID => 1self::NAME => 2self::DESCRIPTION => 3self::SERVICE => 4self::IP => 5self::STATE => 6self::CREATED_AT => 7self::UPDATED_AT => 8),
  96.         BasePeer::TYPE_FIELDNAME => array ('id' => 0'server_id' => 1'name' => 2'description' => 3'service' => 4'ip' => 5'state' => 6'created_at' => 7'updated_at' => 8),
  97.         BasePeer::TYPE_NUM => array (012345678)
  98.     );
  99.  
  100.     /**
  101.      * Get a (singleton) instance of the MapBuilder for this peer class.
  102.      * @return     MapBuilder The map builder for this peer
  103.      */
  104.     public static function getMapBuilder()
  105.     {
  106.         if (self::$mapBuilder === null{
  107.             self::$mapBuilder new EtvaAgentMapBuilder();
  108.         }
  109.         return self::$mapBuilder;
  110.     }
  111.     /**
  112.      * Translates a fieldname to another type
  113.      *
  114.      * @param      string $name field name
  115.      * @param      string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  116.      *                          BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  117.      * @param      string $toType   One of the class type constants
  118.      * @return     string translated name of the field.
  119.      * @throws     PropelException - if the specified name could not be found in the fieldname mappings.
  120.      */
  121.     static public function translateFieldName($name$fromType$toType)
  122.     {
  123.         $toNames self::getFieldNames($toType);
  124.         $key = isset(self::$fieldKeys[$fromType][$name]self::$fieldKeys[$fromType][$namenull;
  125.         if ($key === null{
  126.             throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: print_r(self::$fieldKeys[$fromType]true));
  127.         }
  128.         return $toNames[$key];
  129.     }
  130.  
  131.     /**
  132.      * Returns an array of field names.
  133.      *
  134.      * @param      string $type The type of fieldnames to return:
  135.      *                       One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  136.      *                       BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  137.      * @return     array A list of field names
  138.      */
  139.  
  140.     static public function getFieldNames($type BasePeer::TYPE_PHPNAME)
  141.     {
  142.         if (!array_key_exists($typeself::$fieldNames)) {
  143.             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.');
  144.         }
  145.         return self::$fieldNames[$type];
  146.     }
  147.  
  148.     /**
  149.      * Convenience method which changes table.column to alias.column.
  150.      *
  151.      * Using this method you can maintain SQL abstraction while using column aliases.
  152.      * <code>
  153.      *        $c->addAlias("alias1", TablePeer::TABLE_NAME);
  154.      *        $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
  155.      * </code>
  156.      * @param      string $alias The alias for the current table.
  157.      * @param      string $column The column name for current table. (i.e. EtvaAgentPeer::COLUMN_NAME).
  158.      * @return     string 
  159.      */
  160.     public static function alias($alias$column)
  161.     {
  162.         return str_replace(EtvaAgentPeer::TABLE_NAME.'.'$alias.'.'$column);
  163.     }
  164.  
  165.     /**
  166.      * Add all the columns needed to create a new object.
  167.      *
  168.      * Note: any columns that were marked with lazyLoad="true" in the
  169.      * XML schema will not be added to the select list and only loaded
  170.      * on demand.
  171.      *
  172.      * @param      criteria object containing the columns to add.
  173.      * @throws     PropelException Any exceptions caught during processing will be
  174.      *          rethrown wrapped into a PropelException.
  175.      */
  176.     public static function addSelectColumns(Criteria $criteria)
  177.     {
  178.  
  179.         $criteria->addSelectColumn(EtvaAgentPeer::ID);
  180.  
  181.         $criteria->addSelectColumn(EtvaAgentPeer::SERVER_ID);
  182.  
  183.         $criteria->addSelectColumn(EtvaAgentPeer::NAME);
  184.  
  185.         $criteria->addSelectColumn(EtvaAgentPeer::DESCRIPTION);
  186.  
  187.         $criteria->addSelectColumn(EtvaAgentPeer::SERVICE);
  188.  
  189.         $criteria->addSelectColumn(EtvaAgentPeer::IP);
  190.  
  191.         $criteria->addSelectColumn(EtvaAgentPeer::STATE);
  192.  
  193.         $criteria->addSelectColumn(EtvaAgentPeer::CREATED_AT);
  194.  
  195.         $criteria->addSelectColumn(EtvaAgentPeer::UPDATED_AT);
  196.  
  197.     }
  198.  
  199.     /**
  200.      * Returns the number of rows matching criteria.
  201.      *
  202.      * @param      Criteria $criteria 
  203.      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  204.      * @param      PropelPDO $con 
  205.      * @return     int Number of matching rows.
  206.      */
  207.     public static function doCount(Criteria $criteria$distinct falsePropelPDO $con null)
  208.     {
  209.         // we may modify criteria, so copy it first
  210.         $criteria clone $criteria;
  211.  
  212.         // We need to set the primary table name, since in the case that there are no WHERE columns
  213.         // it will be impossible for the BasePeer::createSelectSql() method to determine which
  214.         // tables go into the FROM clause.
  215.         $criteria->setPrimaryTableName(EtvaAgentPeer::TABLE_NAME);
  216.  
  217.         if ($distinct && !in_array(Criteria::DISTINCT$criteria->getSelectModifiers())) {
  218.             $criteria->setDistinct();
  219.         }
  220.  
  221.         if (!$criteria->hasSelectClause()) {
  222.             EtvaAgentPeer::addSelectColumns($criteria);
  223.         }
  224.  
  225.         $criteria->clearOrderByColumns()// ORDER BY won't ever affect the count
  226.         $criteria->setDbName(self::DATABASE_NAME)// Set the correct dbName
  227.  
  228.         if ($con === null{
  229.             $con Propel::getConnection(EtvaAgentPeer::DATABASE_NAMEPropel::CONNECTION_READ);
  230.         }
  231.  
  232.  
  233.     foreach (sfMixer::getCallables('BaseEtvaAgentPeer:doCount:doCount'as $callable)
  234.     {
  235.       call_user_func($callable'BaseEtvaAgentPeer'$criteria$con);
  236.     }
  237.  
  238.  
  239.         // BasePeer returns a PDOStatement
  240.         $stmt BasePeer::doCount($criteria$con);
  241.  
  242.         if ($row $stmt->fetch(PDO::FETCH_NUM)) {
  243.             $count = (int) $row[0];
  244.         else {
  245.             $count 0// no rows returned; we infer that means 0 matches.
  246.         }
  247.         $stmt->closeCursor();
  248.         return $count;
  249.     }
  250.     /**
  251.      * Method to select one object from the DB.
  252.      *
  253.      * @param      Criteria $criteria object used to create the SELECT statement.
  254.      * @param      PropelPDO $con 
  255.      * @return     EtvaAgent 
  256.      * @throws     PropelException Any exceptions caught during processing will be
  257.      *          rethrown wrapped into a PropelException.
  258.      */
  259.     public static function doSelectOne(Criteria $criteriaPropelPDO $con null)
  260.     {
  261.         $critcopy clone $criteria;
  262.         $critcopy->setLimit(1);
  263.         $objects EtvaAgentPeer::doSelect($critcopy$con);
  264.         if ($objects{
  265.             return $objects[0];
  266.         }
  267.         return null;
  268.     }
  269.     /**
  270.      * Method to do selects.
  271.      *
  272.      * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
  273.      * @param      PropelPDO $con 
  274.      * @return     array Array of selected Objects
  275.      * @throws     PropelException Any exceptions caught during processing will be
  276.      *          rethrown wrapped into a PropelException.
  277.      */
  278.     public static function doSelect(Criteria $criteriaPropelPDO $con null)
  279.     {
  280.         return EtvaAgentPeer::populateObjects(EtvaAgentPeer::doSelectStmt($criteria$con));
  281.     }
  282.     /**
  283.      * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
  284.      *
  285.      * Use this method directly if you want to work with an executed statement durirectly (for example
  286.      * to perform your own object hydration).
  287.      *
  288.      * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
  289.      * @param      PropelPDO $con The connection to use
  290.      * @throws     PropelException Any exceptions caught during processing will be
  291.      *          rethrown wrapped into a PropelException.
  292.      * @return     PDOStatement The executed PDOStatement object.
  293.      * @see        BasePeer::doSelect()
  294.      */
  295.     public static function doSelectStmt(Criteria $criteriaPropelPDO $con null)
  296.     {
  297.  
  298.     foreach (sfMixer::getCallables('BaseEtvaAgentPeer:doSelectStmt:doSelectStmt'as $callable)
  299.     {
  300.       call_user_func($callable'BaseEtvaAgentPeer'$criteria$con);
  301.     }
  302.  
  303.  
  304.         if ($con === null{
  305.             $con Propel::getConnection(EtvaAgentPeer::DATABASE_NAMEPropel::CONNECTION_READ);
  306.         }
  307.  
  308.         if (!$criteria->hasSelectClause()) {
  309.             $criteria clone $criteria;
  310.             EtvaAgentPeer::addSelectColumns($criteria);
  311.         }
  312.  
  313.         // Set the correct dbName
  314.         $criteria->setDbName(self::DATABASE_NAME);
  315.  
  316.         // BasePeer returns a PDOStatement
  317.         return BasePeer::doSelect($criteria$con);
  318.     }
  319.     /**
  320.      * Adds an object to the instance pool.
  321.      *
  322.      * Propel keeps cached copies of objects in an instance pool when they are retrieved
  323.      * from the database.  In some cases -- especially when you override doSelect*()
  324.      * methods in your stub classes -- you may need to explicitly add objects
  325.      * to the cache in order to ensure that the same objects are always returned by doSelect*()
  326.      * and retrieveByPK*() calls.
  327.      *
  328.      * @param      EtvaAgent $value A EtvaAgent object.
  329.      * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  330.      */
  331.     public static function addInstanceToPool(EtvaAgent $obj$key null)
  332.     {
  333.         if (Propel::isInstancePoolingEnabled()) {
  334.             if ($key === null{
  335.                 $key = (string) $obj->getId();
  336.             // if key === null
  337.             self::$instances[$key$obj;
  338.         }
  339.     }
  340.  
  341.     /**
  342.      * Removes an object from the instance pool.
  343.      *
  344.      * Propel keeps cached copies of objects in an instance pool when they are retrieved
  345.      * from the database.  In some cases -- especially when you override doDelete
  346.      * methods in your stub classes -- you may need to explicitly remove objects
  347.      * from the cache in order to prevent returning objects that no longer exist.
  348.      *
  349.      * @param      mixed $value A EtvaAgent object or a primary key value.
  350.      */
  351.     public static function removeInstanceFromPool($value)
  352.     {
  353.         if (Propel::isInstancePoolingEnabled(&& $value !== null{
  354.             if (is_object($value&& $value instanceof EtvaAgent{
  355.                 $key = (string) $value->getId();
  356.             elseif (is_scalar($value)) {
  357.                 // assume we've been passed a primary key
  358.                 $key = (string) $value;
  359.             else {
  360.                 $e new PropelException("Invalid value passed to removeInstanceFromPool().  Expected primary key or EtvaAgent object; got " (is_object($valueget_class($value' object.' var_export($value,true)));
  361.                 throw $e;
  362.             }
  363.  
  364.             unset(self::$instances[$key]);
  365.         }
  366.     // removeInstanceFromPool()
  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      string $key The key (@see getPrimaryKeyHash()) for this instance.
  375.      * @return     EtvaAgent Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled.
  376.      * @see        getPrimaryKeyHash()
  377.      */
  378.     public static function getInstanceFromPool($key)
  379.     {
  380.         if (Propel::isInstancePoolingEnabled()) {
  381.             if (isset(self::$instances[$key])) {
  382.                 return self::$instances[$key];
  383.             }
  384.         }
  385.         return null// just to be explicit
  386.     }
  387.     
  388.     /**
  389.      * Clear the instance pool.
  390.      *
  391.      * @return     void 
  392.      */
  393.     public static function clearInstancePool()
  394.     {
  395.         self::$instances array();
  396.     }
  397.     
  398.     /**
  399.      * 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.
  400.      *
  401.      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
  402.      * a multi-column primary key, a serialize()d version of the primary key will be returned.
  403.      *
  404.      * @param      array $row PropelPDO resultset row.
  405.      * @param      int $startcol The 0-based offset for reading from the resultset row.
  406.      * @return     string A string version of PK or NULL if the components of primary key in result array are all null.
  407.      */
  408.     public static function getPrimaryKeyHashFromRow($row$startcol 0)
  409.     {
  410.         // If the PK cannot be derived from the row, return NULL.
  411.         if ($row[$startcol 0=== null{
  412.             return null;
  413.         }
  414.         return (string) $row[$startcol 0];
  415.     }
  416.  
  417.     /**
  418.      * The returned array will contain objects of the default type or
  419.      * objects that inherit from the default.
  420.      *
  421.      * @throws     PropelException Any exceptions caught during processing will be
  422.      *          rethrown wrapped into a PropelException.
  423.      */
  424.     public static function populateObjects(PDOStatement $stmt)
  425.     {
  426.         $results array();
  427.     
  428.         // set the class once to avoid overhead in the loop
  429.         $cls EtvaAgentPeer::getOMClass();
  430.         $cls substr('.'.$clsstrrpos('.'.$cls'.'1);
  431.         // populate the object(s)
  432.         while ($row $stmt->fetch(PDO::FETCH_NUM)) {
  433.             $key EtvaAgentPeer::getPrimaryKeyHashFromRow($row0);
  434.             if (null !== ($obj EtvaAgentPeer::getInstanceFromPool($key))) {
  435.                 // We no longer rehydrate the object, since this can cause data loss.
  436.                 // See http://propel.phpdb.org/trac/ticket/509
  437.                 // $obj->hydrate($row, 0, true); // rehydrate
  438.                 $results[$obj;
  439.             else {
  440.         
  441.                 $obj new $cls();
  442.                 $obj->hydrate($row);
  443.                 $results[$obj;
  444.                 EtvaAgentPeer::addInstanceToPool($obj$key);
  445.             // if key exists
  446.         }
  447.         $stmt->closeCursor();
  448.         return $results;
  449.     }
  450.  
  451.     /**
  452.      * Returns the number of rows matching criteria, joining the related EtvaServer table
  453.      *
  454.      * @param      Criteria $c 
  455.      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  456.      * @param      PropelPDO $con 
  457.      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  458.      * @return     int Number of matching rows.
  459.      */
  460.     public static function doCountJoinEtvaServer(Criteria $criteria$distinct falsePropelPDO $con null$join_behavior Criteria::LEFT_JOIN)
  461.     {
  462.         // we're going to modify criteria, so copy it first
  463.         $criteria clone $criteria;
  464.  
  465.         // We need to set the primary table name, since in the case that there are no WHERE columns
  466.         // it will be impossible for the BasePeer::createSelectSql() method to determine which
  467.         // tables go into the FROM clause.
  468.         $criteria->setPrimaryTableName(EtvaAgentPeer::TABLE_NAME);
  469.  
  470.         if ($distinct && !in_array(Criteria::DISTINCT$criteria->getSelectModifiers())) {
  471.             $criteria->setDistinct();
  472.         }
  473.  
  474.         if (!$criteria->hasSelectClause()) {
  475.             EtvaAgentPeer::addSelectColumns($criteria);
  476.         }
  477.  
  478.         $criteria->clearOrderByColumns()// ORDER BY won't ever affect the count
  479.  
  480.         // Set the correct dbName
  481.         $criteria->setDbName(self::DATABASE_NAME);
  482.  
  483.         if ($con === null{
  484.             $con Propel::getConnection(EtvaAgentPeer::DATABASE_NAMEPropel::CONNECTION_READ);
  485.         }
  486.  
  487.         $criteria->addJoin(array(EtvaAgentPeer::SERVER_ID,)array(EtvaServerPeer::ID,)$join_behavior);
  488.  
  489.  
  490.     foreach (sfMixer::getCallables('BaseEtvaAgentPeer:doCount:doCount'as $callable)
  491.     {
  492.       call_user_func($callable'BaseEtvaAgentPeer'$criteria$con);
  493.     }
  494.  
  495.  
  496.         $stmt BasePeer::doCount($criteria$con);
  497.  
  498.         if ($row $stmt->fetch(PDO::FETCH_NUM)) {
  499.             $count = (int) $row[0];
  500.         else {
  501.             $count 0// no rows returned; we infer that means 0 matches.
  502.         }
  503.         $stmt->closeCursor();
  504.         return $count;
  505.     }
  506.  
  507.  
  508.     /**
  509.      * Selects a collection of EtvaAgent objects pre-filled with their EtvaServer objects.
  510.      * @param      Criteria  $c 
  511.      * @param      PropelPDO $con 
  512.      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  513.      * @return     array Array of EtvaAgent objects.
  514.      * @throws     PropelException Any exceptions caught during processing will be
  515.      *          rethrown wrapped into a PropelException.
  516.      */
  517.     public static function doSelectJoinEtvaServer(Criteria $c$con null$join_behavior Criteria::LEFT_JOIN)
  518.     {
  519.  
  520.     foreach (sfMixer::getCallables('BaseEtvaAgentPeer:doSelectJoin:doSelectJoin'as $callable)
  521.     {
  522.       call_user_func($callable'BaseEtvaAgentPeer'$c$con);
  523.     }
  524.  
  525.  
  526.         $c clone $c;
  527.  
  528.         // Set the correct dbName if it has not been overridden
  529.         if ($c->getDbName(== Propel::getDefaultDB()) {
  530.             $c->setDbName(self::DATABASE_NAME);
  531.         }
  532.  
  533.         EtvaAgentPeer::addSelectColumns($c);
  534.         $startcol (EtvaAgentPeer::NUM_COLUMNS EtvaAgentPeer::NUM_LAZY_LOAD_COLUMNS);
  535.         EtvaServerPeer::addSelectColumns($c);
  536.  
  537.         $c->addJoin(array(EtvaAgentPeer::SERVER_ID,)array(EtvaServerPeer::ID,)$join_behavior);
  538.         $stmt BasePeer::doSelect($c$con);
  539.         $results array();
  540.  
  541.         while ($row $stmt->fetch(PDO::FETCH_NUM)) {
  542.             $key1 EtvaAgentPeer::getPrimaryKeyHashFromRow($row0);
  543.             if (null !== ($obj1 EtvaAgentPeer::getInstanceFromPool($key1))) {
  544.                 // We no longer rehydrate the object, since this can cause data loss.
  545.                 // See http://propel.phpdb.org/trac/ticket/509
  546.                 // $obj1->hydrate($row, 0, true); // rehydrate
  547.             else {
  548.  
  549.                 $omClass EtvaAgentPeer::getOMClass();
  550.  
  551.                 $cls substr('.'.$omClassstrrpos('.'.$omClass'.'1);
  552.                 $obj1 new $cls();
  553.                 $obj1->hydrate($row);
  554.                 EtvaAgentPeer::addInstanceToPool($obj1$key1);
  555.             // if $obj1 already loaded
  556.  
  557.             $key2 EtvaServerPeer::getPrimaryKeyHashFromRow($row$startcol);
  558.             if ($key2 !== null{
  559.                 $obj2 EtvaServerPeer::getInstanceFromPool($key2);
  560.                 if (!$obj2{
  561.  
  562.                     $omClass EtvaServerPeer::getOMClass();
  563.  
  564.                     $cls substr('.'.$omClassstrrpos('.'.$omClass'.'1);
  565.                     $obj2 new $cls();
  566.                     $obj2->hydrate($row$startcol);
  567.                     EtvaServerPeer::addInstanceToPool($obj2$key2);
  568.                 // if obj2 already loaded
  569.  
  570.                 // Add the $obj1 (EtvaAgent) to $obj2 (EtvaServer)
  571.                 $obj2->addEtvaAgent($obj1);
  572.  
  573.             // if joined row was not null
  574.  
  575.             $results[$obj1;
  576.         }
  577.         $stmt->closeCursor();
  578.         return $results;
  579.     }
  580.  
  581.  
  582.     /**
  583.      * Returns the number of rows matching criteria, joining all related tables
  584.      *
  585.      * @param      Criteria $c 
  586.      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  587.      * @param      PropelPDO $con 
  588.      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  589.      * @return     int Number of matching rows.
  590.      */
  591.     public static function doCountJoinAll(Criteria $criteria$distinct falsePropelPDO $con null$join_behavior Criteria::LEFT_JOIN)
  592.     {
  593.         // we're going to modify criteria, so copy it first
  594.         $criteria clone $criteria;
  595.  
  596.         // We need to set the primary table name, since in the case that there are no WHERE columns
  597.         // it will be impossible for the BasePeer::createSelectSql() method to determine which
  598.         // tables go into the FROM clause.
  599.         $criteria->setPrimaryTableName(EtvaAgentPeer::TABLE_NAME);
  600.  
  601.         if ($distinct && !in_array(Criteria::DISTINCT$criteria->getSelectModifiers())) {
  602.             $criteria->setDistinct();
  603.         }
  604.  
  605.         if (!$criteria->hasSelectClause()) {
  606.             EtvaAgentPeer::addSelectColumns($criteria);
  607.         }
  608.  
  609.         $criteria->clearOrderByColumns()// ORDER BY won't ever affect the count
  610.  
  611.         // Set the correct dbName
  612.         $criteria->setDbName(self::DATABASE_NAME);
  613.  
  614.         if ($con === null{
  615.             $con Propel::getConnection(EtvaAgentPeer::DATABASE_NAMEPropel::CONNECTION_READ);
  616.         }
  617.  
  618.         $criteria->addJoin(array(EtvaAgentPeer::SERVER_ID,)array(EtvaServerPeer::ID,)$join_behavior);
  619.  
  620.     foreach (sfMixer::getCallables('BaseEtvaAgentPeer:doCount:doCount'as $callable)
  621.     {
  622.       call_user_func($callable'BaseEtvaAgentPeer'$criteria$con);
  623.     }
  624.  
  625.  
  626.         $stmt BasePeer::doCount($criteria$con);
  627.  
  628.         if ($row $stmt->fetch(PDO::FETCH_NUM)) {
  629.             $count = (int) $row[0];
  630.         else {
  631.             $count 0// no rows returned; we infer that means 0 matches.
  632.         }
  633.         $stmt->closeCursor();
  634.         return $count;
  635.     }
  636.  
  637.     /**
  638.      * Selects a collection of EtvaAgent objects pre-filled with all related objects.
  639.      *
  640.      * @param      Criteria  $c 
  641.      * @param      PropelPDO $con 
  642.      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  643.      * @return     array Array of EtvaAgent objects.
  644.      * @throws     PropelException Any exceptions caught during processing will be
  645.      *          rethrown wrapped into a PropelException.
  646.      */
  647.     public static function doSelectJoinAll(Criteria $c$con null$join_behavior Criteria::LEFT_JOIN)
  648.     {
  649.  
  650.     foreach (sfMixer::getCallables('BaseEtvaAgentPeer:doSelectJoinAll:doSelectJoinAll'as $callable)
  651.     {
  652.       call_user_func($callable'BaseEtvaAgentPeer'$c$con);
  653.     }
  654.  
  655.  
  656.         $c clone $c;
  657.  
  658.         // Set the correct dbName if it has not been overridden
  659.         if ($c->getDbName(== Propel::getDefaultDB()) {
  660.             $c->setDbName(self::DATABASE_NAME);
  661.         }
  662.  
  663.         EtvaAgentPeer::addSelectColumns($c);
  664.         $startcol2 (EtvaAgentPeer::NUM_COLUMNS EtvaAgentPeer::NUM_LAZY_LOAD_COLUMNS);
  665.  
  666.         EtvaServerPeer::addSelectColumns($c);
  667.         $startcol3 $startcol2 (EtvaServerPeer::NUM_COLUMNS EtvaServerPeer::NUM_LAZY_LOAD_COLUMNS);
  668.  
  669.         $c->addJoin(array(EtvaAgentPeer::SERVER_ID,)array(EtvaServerPeer::ID,)$join_behavior);
  670.         $stmt BasePeer::doSelect($c$con);
  671.         $results array();
  672.  
  673.         while ($row $stmt->fetch(PDO::FETCH_NUM)) {
  674.             $key1 EtvaAgentPeer::getPrimaryKeyHashFromRow($row0);
  675.             if (null !== ($obj1 EtvaAgentPeer::getInstanceFromPool($key1))) {
  676.                 // We no longer rehydrate the object, since this can cause data loss.
  677.                 // See http://propel.phpdb.org/trac/ticket/509
  678.                 // $obj1->hydrate($row, 0, true); // rehydrate
  679.             else {
  680.                 $omClass EtvaAgentPeer::getOMClass();
  681.  
  682.                 $cls substr('.'.$omClassstrrpos('.'.$omClass'.'1);
  683.                 $obj1 new $cls();
  684.                 $obj1->hydrate($row);
  685.                 EtvaAgentPeer::addInstanceToPool($obj1$key1);
  686.             // if obj1 already loaded
  687.  
  688.             // Add objects for joined EtvaServer rows
  689.  
  690.             $key2 EtvaServerPeer::getPrimaryKeyHashFromRow($row$startcol2);
  691.             if ($key2 !== null{
  692.                 $obj2 EtvaServerPeer::getInstanceFromPool($key2);
  693.                 if (!$obj2{
  694.  
  695.                     $omClass EtvaServerPeer::getOMClass();
  696.  
  697.  
  698.                     $cls substr('.'.$omClassstrrpos('.'.$omClass'.'1);
  699.                     $obj2 new $cls();
  700.                     $obj2->hydrate($row$startcol2);
  701.                     EtvaServerPeer::addInstanceToPool($obj2$key2);
  702.                 // if obj2 loaded
  703.  
  704.                 // Add the $obj1 (EtvaAgent) to the collection in $obj2 (EtvaServer)
  705.                 $obj2->addEtvaAgent($obj1);
  706.             // if joined row not null
  707.  
  708.             $results[$obj1;
  709.         }
  710.         $stmt->closeCursor();
  711.         return $results;
  712.     }
  713.  
  714.  
  715.   static public function getUniqueColumnNames()
  716.   {
  717.     return array();
  718.   }
  719.     /**
  720.      * Returns the TableMap related to this peer.
  721.      * This method is not needed for general use but a specific application could have a need.
  722.      * @return     TableMap 
  723.      * @throws     PropelException Any exceptions caught during processing will be
  724.      *          rethrown wrapped into a PropelException.
  725.      */
  726.     public static function getTableMap()
  727.     {
  728.         return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
  729.     }
  730.  
  731.     /**
  732.      * The class that the Peer will make instances of.
  733.      *
  734.      * This uses a dot-path notation which is tranalted into a path
  735.      * relative to a location on the PHP include_path.
  736.      * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
  737.      *
  738.      * @return     string path.to.ClassName
  739.      */
  740.     public static function getOMClass()
  741.     {
  742.         return EtvaAgentPeer::CLASS_DEFAULT;
  743.     }
  744.  
  745.     /**
  746.      * Method perform an INSERT on the database, given a EtvaAgent or Criteria object.
  747.      *
  748.      * @param      mixed $values Criteria or EtvaAgent object containing data that is used to create the INSERT statement.
  749.      * @param      PropelPDO $con the PropelPDO connection to use
  750.      * @return     mixed The new primary key.
  751.      * @throws     PropelException Any exceptions caught during processing will be
  752.      *          rethrown wrapped into a PropelException.
  753.      */
  754.     public static function doInsert($valuesPropelPDO $con null)
  755.     {
  756.  
  757.     foreach (sfMixer::getCallables('BaseEtvaAgentPeer:doInsert:pre'as $callable)
  758.     {
  759.       $ret call_user_func($callable'BaseEtvaAgentPeer'$values$con);
  760.       if (false !== $ret)
  761.       {
  762.         return $ret;
  763.       }
  764.     }
  765.  
  766.  
  767.         if ($con === null{
  768.             $con Propel::getConnection(EtvaAgentPeer::DATABASE_NAMEPropel::CONNECTION_WRITE);
  769.         }
  770.  
  771.         if ($values instanceof Criteria{
  772.             $criteria clone $values// rename for clarity
  773.         else {
  774.             $criteria $values->buildCriteria()// build Criteria from EtvaAgent object
  775.         }
  776.  
  777.         if ($criteria->containsKey(EtvaAgentPeer::ID&& $criteria->keyContainsValue(EtvaAgentPeer::ID) ) {
  778.             throw new PropelException('Cannot insert a value for auto-increment primary key ('.EtvaAgentPeer::ID.')');
  779.         }
  780.  
  781.  
  782.         // Set the correct dbName
  783.         $criteria->setDbName(self::DATABASE_NAME);
  784.  
  785.         try {
  786.             // use transaction because $criteria could contain info
  787.             // for more than one table (I guess, conceivably)
  788.             $con->beginTransaction();
  789.             $pk BasePeer::doInsert($criteria$con);
  790.             $con->commit();
  791.         catch(PropelException $e{
  792.             $con->rollBack();
  793.             throw $e;
  794.         }
  795.  
  796.         
  797.     foreach (sfMixer::getCallables('BaseEtvaAgentPeer:doInsert:post'as $callable)
  798.     {
  799.       call_user_func($callable'BaseEtvaAgentPeer'$values$con$pk);
  800.     }
  801.  
  802.     return $pk;
  803.     }
  804.  
  805.     /**
  806.      * Method perform an UPDATE on the database, given a EtvaAgent or Criteria object.
  807.      *
  808.      * @param      mixed $values Criteria or EtvaAgent object containing data that is used to create the UPDATE statement.
  809.      * @param      PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
  810.      * @return     int The number of affected rows (if supported by underlying database driver).
  811.      * @throws     PropelException Any exceptions caught during processing will be
  812.      *          rethrown wrapped into a PropelException.
  813.      */
  814.     public static function doUpdate($valuesPropelPDO $con null)
  815.     {
  816.  
  817.     foreach (sfMixer::getCallables('BaseEtvaAgentPeer:doUpdate:pre'as $callable)
  818.     {
  819.       $ret call_user_func($callable'BaseEtvaAgentPeer'$values$con);
  820.       if (false !== $ret)
  821.       {
  822.         return $ret;
  823.       }
  824.     }
  825.  
  826.  
  827.         if ($con === null{
  828.             $con Propel::getConnection(EtvaAgentPeer::DATABASE_NAMEPropel::CONNECTION_WRITE);
  829.         }
  830.  
  831.         $selectCriteria new Criteria(self::DATABASE_NAME);
  832.  
  833.         if ($values instanceof Criteria{
  834.             $criteria clone $values// rename for clarity
  835.  
  836.             $comparison $criteria->getComparison(EtvaAgentPeer::ID);
  837.             $selectCriteria->add(EtvaAgentPeer::ID$criteria->remove(EtvaAgentPeer::ID)$comparison);
  838.  
  839.         else // $values is EtvaAgent object
  840.             $criteria $values->buildCriteria()// gets full criteria
  841.             $selectCriteria $values->buildPkeyCriteria()// gets criteria w/ primary key(s)
  842.         }
  843.  
  844.         // set the correct dbName
  845.         $criteria->setDbName(self::DATABASE_NAME);
  846.  
  847.         $ret BasePeer::doUpdate($selectCriteria$criteria$con);
  848.     
  849.  
  850.     foreach (sfMixer::getCallables('BaseEtvaAgentPeer:doUpdate:post'as $callable)
  851.     {
  852.       call_user_func($callable'BaseEtvaAgentPeer'$values$con$ret);
  853.     }
  854.  
  855.     return $ret;
  856.   }
  857.  
  858.     /**
  859.      * Method to DELETE all rows from the agent table.
  860.      *
  861.      * @return     int The number of affected rows (if supported by underlying database driver).
  862.      */
  863.     public static function doDeleteAll($con null)
  864.     {
  865.         if ($con === null{
  866.             $con Propel::getConnection(EtvaAgentPeer::DATABASE_NAMEPropel::CONNECTION_WRITE);
  867.         }
  868.         $affectedRows 0// initialize var to track total num of affected rows
  869.         try {
  870.             // use transaction because $criteria could contain info
  871.             // for more than one table or we could emulating ON DELETE CASCADE, etc.
  872.             $con->beginTransaction();
  873.             $affectedRows += BasePeer::doDeleteAll(EtvaAgentPeer::TABLE_NAME$con);
  874.             $con->commit();
  875.             return $affectedRows;
  876.         catch (PropelException $e{
  877.             $con->rollBack();
  878.             throw $e;
  879.         }
  880.     }
  881.  
  882.     /**
  883.      * Method perform a DELETE on the database, given a EtvaAgent or Criteria object OR a primary key value.
  884.      *
  885.      * @param      mixed $values Criteria or EtvaAgent object or primary key or array of primary keys
  886.      *               which is used to create the DELETE statement
  887.      * @param      PropelPDO $con the connection to use
  888.      * @return     int     The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
  889.      *                 if supported by native driver or if emulated using Propel.
  890.      * @throws     PropelException Any exceptions caught during processing will be
  891.      *          rethrown wrapped into a PropelException.
  892.      */
  893.      public static function doDelete($valuesPropelPDO $con null)
  894.      {
  895.         if ($con === null{
  896.             $con Propel::getConnection(EtvaAgentPeer::DATABASE_NAMEPropel::CONNECTION_WRITE);
  897.         }
  898.  
  899.         if ($values instanceof Criteria{
  900.             // invalidate the cache for all objects of this type, since we have no
  901.             // way of knowing (without running a query) what objects should be invalidated
  902.             // from the cache based on this Criteria.
  903.             EtvaAgentPeer::clearInstancePool();
  904.  
  905.             // rename for clarity
  906.             $criteria clone $values;
  907.         elseif ($values instanceof EtvaAgent{
  908.             // invalidate the cache for this single object
  909.             EtvaAgentPeer::removeInstanceFromPool($values);
  910.             // create criteria based on pk values
  911.             $criteria $values->buildPkeyCriteria();
  912.         else {
  913.             // it must be the primary key
  914.  
  915.  
  916.  
  917.             $criteria new Criteria(self::DATABASE_NAME);
  918.             $criteria->add(EtvaAgentPeer::ID(array) $valuesCriteria::IN);
  919.  
  920.             foreach ((array) $values as $singleval{
  921.                 // we can invalidate the cache for this single object
  922.                 EtvaAgentPeer::removeInstanceFromPool($singleval);
  923.             }
  924.         }
  925.  
  926.         // Set the correct dbName
  927.         $criteria->setDbName(self::DATABASE_NAME);
  928.  
  929.         $affectedRows 0// initialize var to track total num of affected rows
  930.  
  931.         try {
  932.             // use transaction because $criteria could contain info
  933.             // for more than one table or we could emulating ON DELETE CASCADE, etc.
  934.             $con->beginTransaction();
  935.             
  936.             $affectedRows += BasePeer::doDelete($criteria$con);
  937.  
  938.             $con->commit();
  939.             return $affectedRows;
  940.         catch (PropelException $e{
  941.             $con->rollBack();
  942.             throw $e;
  943.         }
  944.     }
  945.  
  946.     /**
  947.      * Validates all modified columns of given EtvaAgent object.
  948.      * If parameter $columns is either a single column name or an array of column names
  949.      * than only those columns are validated.
  950.      *
  951.      * NOTICE: This does not apply to primary or foreign keys for now.
  952.      *
  953.      * @param      EtvaAgent $obj The object to validate.
  954.      * @param      mixed $cols Column name or array of column names.
  955.      *
  956.      * @return     mixed TRUE if all columns are valid or the error message of the first invalid column.
  957.      */
  958.     public static function doValidate(EtvaAgent $obj$cols null)
  959.     {
  960.         $columns array();
  961.  
  962.         if ($cols{
  963.             $dbMap Propel::getDatabaseMap(EtvaAgentPeer::DATABASE_NAME);
  964.             $tableMap $dbMap->getTable(EtvaAgentPeer::TABLE_NAME);
  965.  
  966.             if (is_array($cols)) {
  967.                 $cols array($cols);
  968.             }
  969.  
  970.             foreach ($cols as $colName{
  971.                 if ($tableMap->containsColumn($colName)) {
  972.                     $get 'get' $tableMap->getColumn($colName)->getPhpName();
  973.                     $columns[$colName$obj->$get();
  974.                 }
  975.             }
  976.         else {
  977.  
  978.         }
  979.  
  980.         $res =  BasePeer::doValidate(EtvaAgentPeer::DATABASE_NAMEEtvaAgentPeer::TABLE_NAME$columns);
  981.     if ($res !== true{
  982.         $request sfContext::getInstance()->getRequest();
  983.         foreach ($res as $failed{
  984.             $col EtvaAgentPeer::translateFieldname($failed->getColumn()BasePeer::TYPE_COLNAMEBasePeer::TYPE_PHPNAME);
  985.         }
  986.     }
  987.  
  988.     return $res;
  989.     }
  990.  
  991.     /**
  992.      * Retrieve a single object by pkey.
  993.      *
  994.      * @param      int $pk the primary key.
  995.      * @param      PropelPDO $con the connection to use
  996.      * @return     EtvaAgent 
  997.      */
  998.     public static function retrieveByPK($pkPropelPDO $con null)
  999.     {
  1000.  
  1001.         if (null !== ($obj EtvaAgentPeer::getInstanceFromPool((string) $pk))) {
  1002.             return $obj;
  1003.         }
  1004.  
  1005.         if ($con === null{
  1006.             $con Propel::getConnection(EtvaAgentPeer::DATABASE_NAMEPropel::CONNECTION_READ);
  1007.         }
  1008.  
  1009.         $criteria new Criteria(EtvaAgentPeer::DATABASE_NAME);
  1010.         $criteria->add(EtvaAgentPeer::ID$pk);
  1011.  
  1012.         $v EtvaAgentPeer::doSelect($criteria$con);
  1013.  
  1014.         return !empty($v$v[0null;
  1015.     }
  1016.  
  1017.     /**
  1018.      * Retrieve multiple objects by pkey.
  1019.      *
  1020.      * @param      array $pks List of primary keys
  1021.      * @param      PropelPDO $con the connection to use
  1022.      * @throws     PropelException Any exceptions caught during processing will be
  1023.      *          rethrown wrapped into a PropelException.
  1024.      */
  1025.     public static function retrieveByPKs($pksPropelPDO $con null)
  1026.     {
  1027.         if ($con === null{
  1028.             $con Propel::getConnection(EtvaAgentPeer::DATABASE_NAMEPropel::CONNECTION_READ);
  1029.         }
  1030.  
  1031.         $objs null;
  1032.         if (empty($pks)) {
  1033.             $objs array();
  1034.         else {
  1035.             $criteria new Criteria(EtvaAgentPeer::DATABASE_NAME);
  1036.             $criteria->add(EtvaAgentPeer::ID$pksCriteria::IN);
  1037.             $objs EtvaAgentPeer::doSelect($criteria$con);
  1038.         }
  1039.         return $objs;
  1040.     }
  1041.  
  1042. // BaseEtvaAgentPeer
  1043.  
  1044. // This is the static code needed to register the MapBuilder for this table with the main Propel class.
  1045. //
  1046. // NOTE: This static code cannot call methods on the EtvaAgentPeer class, because it is not defined yet.
  1047. // If you need to use overridden methods, you can add this code to the bottom of the EtvaAgentPeer class:
  1048. //
  1049. // Propel::getDatabaseMap(EtvaAgentPeer::DATABASE_NAME)->addTableBuilder(EtvaAgentPeer::TABLE_NAME, EtvaAgentPeer::getMapBuilder());
  1050. //
  1051. // Doing so will effectively overwrite the registration below.
  1052.  
  1053. Propel::getDatabaseMap(BaseEtvaAgentPeer::DATABASE_NAME)->addTableBuilder(BaseEtvaAgentPeer::TABLE_NAMEBaseEtvaAgentPeer::getMapBuilder());

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