[geeklog-cvs] Geeklog-2/system/Propel/Geeklog-2/om BaseGl2Timezone.php,NONE,1.1 BaseGl2TimezonePeer.php,NONE,1.1

tony at iowaoutdoors.org tony at iowaoutdoors.org
Mon Dec 20 17:10:38 EST 2004


Update of /var/cvs/Geeklog-2/system/Propel/Geeklog-2/om
In directory www:/tmp/cvs-serv28006/Propel/Geeklog-2/om

Added Files:
	BaseGl2Timezone.php BaseGl2TimezonePeer.php 
Log Message:
Some new files.  Not sure why all propel classes are listed every time...sorry


--- NEW FILE: BaseGl2Timezone.php ---
<?php 

require_once 'propel/om/BaseObject.php';

require_once 'propel/om/Persistent.php';
 

include_once 'propel/util/Criteria.php';

include_once 'Geeklog-2/Gl2TimezonePeer.php';

/**
 * Base class that represents a row from the 'gl2_timezone' table.
 *
 *  *
 * This class was autogenerated by Propel on:
 *
 * [Mon Dec 20 15:25:53 2004]
 *
 * You should not use this class directly.  It should not even be
 * extended; all references should be to Gl2Timezone class. 
 * 
 * @package Geeklog-2 
 */
abstract class BaseGl2Timezone extends BaseObject implements Persistent {
    
    /** 
     * The Peer class.
     * Instance provides a convenient way of calling static methods on a class
     * that calling code may not be able to identify.
     * @var Gl2TimezonePeer
     */
    protected static $peer;

    /**
     * The value for the timezone_id field.
     * @var int      
     */
    protected $timezone_id;    

    /**
     * The value for the code field.
     * @var string      
     */
    protected $code = '';    

    /**
     * The value for the offset field.
     * @var int      
     */
    protected $offset = 0;    

    /**
     * The value for the description field.
     * @var string      
     */
    protected $description;    
  
    /**
     * Get the TimezoneId column value.
     *      * @return int      
     */
    public function getTimezoneId()
    {
        return $this->timezone_id;
    }


    /**
     * Set the value of `timezone_id` column.      
     *      * @param int $v new value
     * @return void
     * @throws PropelException 
     */
    public function setTimezoneId($v)
    {
        if ($this->timezone_id !== $v) {
            $this->timezone_id = $v;
            $this->modifiedColumns[] = Gl2TimezonePeer::TIMEZONE_ID;
        }
            
          // update associated Gl2User          
          if ($this->collGl2Users !== null) {
              for ($i=0,$size=count($this->collGl2Users); $i < $size; $i++) {
                  $this->collGl2Users[$i]->setTimezoneId($v);
              }
          }
                      
    }

  
    /**
     * Get the Code column value.
     *      * @return string      
     */
    public function getCode()
    {
        return $this->code;
    }


    /**
     * Set the value of `code` column.      
     *      * @param string $v new value
     * @return void
     *  
     */
    public function setCode($v)
    {
        if ($this->code !== $v) {
            $this->code = $v;
            $this->modifiedColumns[] = Gl2TimezonePeer::CODE;
        }
                
    }

  
    /**
     * Get the Offset column value.
     *      * @return int      
     */
    public function getOffset()
    {
        return $this->offset;
    }


    /**
     * Set the value of `offset` column.      
     *      * @param int $v new value
     * @return void
     *  
     */
    public function setOffset($v)
    {
        if ($this->offset !== $v) {
            $this->offset = $v;
            $this->modifiedColumns[] = Gl2TimezonePeer::OFFSET;
        }
                
    }

  
    /**
     * Get the Description column value.
     *      * @return string      
     */
    public function getDescription()
    {
        return $this->description;
    }


    /**
     * Set the value of `description` column.      
     *      * @param string $v new value
     * @return void
     *  
     */
    public function setDescription($v)
    {
        if ($this->description !== $v) {
            $this->description = $v;
            $this->modifiedColumns[] = Gl2TimezonePeer::DESCRIPTION;
        }
                
    }


    
    /**
     * Hydrates (populates) the object variables with values from the database resultset.
     *
     * An offset (1-based "start column") is specified so that objects can be hydrated
     * with a subset of the columns in the resultset rows.  This is needed, for example,
     * for results of JOIN queries where the resultset row includes columns from two or
     * more tables.
     *
     * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
     * @param int $startcol 1-based offset column which indicates which restultset column to start with.
     * @return void
     * @throws PropelException  - Any caught Exception will be rewrapped as a PropelException.
     */
    public function hydrate(ResultSet $rs, $startcol = 1)
    {
        try {
            $this->timezone_id = $rs->getInt($startcol + 0);                    
            $this->code = $rs->getString($startcol + 1);                    
            $this->offset = $rs->getInt($startcol + 2);                    
            $this->description = $rs->getString($startcol + 3);                    
             
            $this->resetModified();
            $this->setNew(false);
        
        } catch (Exception $e) {
            throw new PropelException("Error populating object", $e);
        }        
    
    }
    
    /**
     * Builds a Criteria object containing the primary key for this object.
     *
     * Unlike buildCriteria() this method includes the primary key values regardless
     * of whether or not they have been modified.
     * 
     * @return Criteria The Criteria object containing value(s) for primary key(s).
     */
    public function buildPkeyCriteria()
    {        
        $criteria = new Criteria(Gl2TimezonePeer::DATABASE_NAME);
        $criteria->add(Gl2TimezonePeer::TIMEZONE_ID, $this->timezone_id);
        return $criteria;            
    }
    
    /**
     * Build a Criteria object containing the values of all modified columns in this object.
     *
     * @return Criteria The Criteria object containing all modified values.
     */
    public function buildCriteria()
    {        
        $criteria = new Criteria(Gl2TimezonePeer::DATABASE_NAME);
        if ($this->isColumnModified(Gl2TimezonePeer::TIMEZONE_ID)) $criteria->add(Gl2TimezonePeer::TIMEZONE_ID, $this->timezone_id);
        if ($this->isColumnModified(Gl2TimezonePeer::CODE)) $criteria->add(Gl2TimezonePeer::CODE, $this->code);
        if ($this->isColumnModified(Gl2TimezonePeer::OFFSET)) $criteria->add(Gl2TimezonePeer::OFFSET, $this->offset);
        if ($this->isColumnModified(Gl2TimezonePeer::DESCRIPTION)) $criteria->add(Gl2TimezonePeer::DESCRIPTION, $this->description);
        return $criteria;            
    }
    
    

    /**
     * Collection to store aggregation of collGl2Users      
     * @var array
     */
    protected $collGl2Users; 

    /**
     * Temporary storage of collGl2Users to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     * @return void
     */
    public function initGl2Users()
    {
        if ($this->collGl2Users === null) {
            $this->collGl2Users = array();
        }
    }

    /**
     * Method called to associate a Gl2User object to this object
     * through the Gl2User foreign key attribute
     *
     * @param Gl2User $l $className
     * @return void
     * @throws PropelException
     */
    public function addGl2User(Gl2User $l)
    {
        $this->collGl2Users[] = $l;
        $l->setGl2Timezone($this);
    }

    /**
     * The criteria used to select the current contents of collGl2Users.
     * @var Criteria
     */
    private $lastGl2UsersCriteria = null;

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Gl2Timezone has previously
     * been saved, it will retrieve related Gl2Users from storage.
     * If this Gl2Timezone is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @param Connection $con
     * @param Criteria $criteria
     * @throws PropelException
     */
    public function getGl2Users($criteria = null, $con = null)
    {
        // include the Peer class
        include_once 'Geeklog-2/Gl2UserPeer.php';
        if ($criteria === null) {
            $criteria = new Criteria();
        }
                
        if ($this->collGl2Users === null) {
            if ($this->isNew()) {
               $this->collGl2Users = array();
            } else {
    
                $criteria->add(Gl2UserPeer::TIMEZONE_ID, $this->getTimezoneId() );

                $this->collGl2Users = Gl2UserPeer::doSelect($criteria, $con);
            }
        } else {
            // criteria has no effect for a new object
            if (!$this->isNew()) {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.

                $criteria->add(Gl2UserPeer::TIMEZONE_ID, $this->getTimezoneId());

                if (!isset($this->lastGl2UsersCriteria) || !$this->lastGl2UsersCriteria->equals($criteria)) {
                    $this->collGl2Users = Gl2UserPeer::doSelect($criteria, $con);
                }
            }
        }
        $this->lastGl2UsersCriteria = $criteria;

        return $this->collGl2Users;
    }
    

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Gl2Timezone is new, it will return
     * an empty collection; or if this Gl2Timezone has previously
     * been saved, it will retrieve related Gl2Users from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Gl2Timezone.
     */
    public function getGl2UsersJoinGl2ListOfValuesRelatedByCommentModeId($criteria = null, $con = null)
    {
        if ($criteria === null) {
            $criteria = new Criteria();
        }
        
        if ($this->collGl2Users === null) {
            if ($this->isNew()) {
               $this->collGl2Users = array();
            } else {
       
                $criteria->add(Gl2UserPeer::TIMEZONE_ID, $this->getTimezoneId());
                $this->collGl2Users = Gl2UserPeer::doSelectJoinGl2ListOfValuesRelatedByCommentModeId($criteria, $con);
            }
        } else {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
      
            $criteria->add(Gl2UserPeer::TIMEZONE_ID, $this->getTimezoneId());
            if (!isset($this->lastGl2UsersCriteria) || !$this->lastGl2UsersCriteria->equals($criteria)) {
                $this->collGl2Users = Gl2UserPeer::doSelectJoinGl2ListOfValuesRelatedByCommentModeId($criteria, $con);
            }
        }
        $this->lastGl2UsersCriteria = $criteria;

        return $this->collGl2Users;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Gl2Timezone is new, it will return
     * an empty collection; or if this Gl2Timezone has previously
     * been saved, it will retrieve related Gl2Users from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Gl2Timezone.
     */
    public function getGl2UsersJoinGl2ListOfValuesRelatedByCommentOrderId($criteria = null, $con = null)
    {
        if ($criteria === null) {
            $criteria = new Criteria();
        }
        
        if ($this->collGl2Users === null) {
            if ($this->isNew()) {
               $this->collGl2Users = array();
            } else {
       
                $criteria->add(Gl2UserPeer::TIMEZONE_ID, $this->getTimezoneId());
                $this->collGl2Users = Gl2UserPeer::doSelectJoinGl2ListOfValuesRelatedByCommentOrderId($criteria, $con);
            }
        } else {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
      
            $criteria->add(Gl2UserPeer::TIMEZONE_ID, $this->getTimezoneId());
            if (!isset($this->lastGl2UsersCriteria) || !$this->lastGl2UsersCriteria->equals($criteria)) {
                $this->collGl2Users = Gl2UserPeer::doSelectJoinGl2ListOfValuesRelatedByCommentOrderId($criteria, $con);
            }
        }
        $this->lastGl2UsersCriteria = $criteria;

        return $this->collGl2Users;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Gl2Timezone is new, it will return
     * an empty collection; or if this Gl2Timezone has previously
     * been saved, it will retrieve related Gl2Users from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Gl2Timezone.
     */
    public function getGl2UsersJoinGl2ListOfValuesRelatedByDateFormatId($criteria = null, $con = null)
    {
        if ($criteria === null) {
            $criteria = new Criteria();
        }
        
        if ($this->collGl2Users === null) {
            if ($this->isNew()) {
               $this->collGl2Users = array();
            } else {
       
                $criteria->add(Gl2UserPeer::TIMEZONE_ID, $this->getTimezoneId());
                $this->collGl2Users = Gl2UserPeer::doSelectJoinGl2ListOfValuesRelatedByDateFormatId($criteria, $con);
            }
        } else {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
      
            $criteria->add(Gl2UserPeer::TIMEZONE_ID, $this->getTimezoneId());
            if (!isset($this->lastGl2UsersCriteria) || !$this->lastGl2UsersCriteria->equals($criteria)) {
                $this->collGl2Users = Gl2UserPeer::doSelectJoinGl2ListOfValuesRelatedByDateFormatId($criteria, $con);
            }
        }
        $this->lastGl2UsersCriteria = $criteria;

        return $this->collGl2Users;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Gl2Timezone is new, it will return
     * an empty collection; or if this Gl2Timezone has previously
     * been saved, it will retrieve related Gl2Users from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Gl2Timezone.
     */
    public function getGl2UsersJoinGl2Timezone($criteria = null, $con = null)
    {
        if ($criteria === null) {
            $criteria = new Criteria();
        }
        
        if ($this->collGl2Users === null) {
            if ($this->isNew()) {
               $this->collGl2Users = array();
            } else {
       
                $criteria->add(Gl2UserPeer::TIMEZONE_ID, $this->getTimezoneId());
                $this->collGl2Users = Gl2UserPeer::doSelectJoinGl2Timezone($criteria, $con);
            }
        } else {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
      
            $criteria->add(Gl2UserPeer::TIMEZONE_ID, $this->getTimezoneId());
            if (!isset($this->lastGl2UsersCriteria) || !$this->lastGl2UsersCriteria->equals($criteria)) {
                $this->collGl2Users = Gl2UserPeer::doSelectJoinGl2Timezone($criteria, $con);
            }
        }
        $this->lastGl2UsersCriteria = $criteria;

        return $this->collGl2Users;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Gl2Timezone is new, it will return
     * an empty collection; or if this Gl2Timezone has previously
     * been saved, it will retrieve related Gl2Users from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Gl2Timezone.
     */
    public function getGl2UsersJoinGl2ListOfValuesRelatedByLocaleId($criteria = null, $con = null)
    {
        if ($criteria === null) {
            $criteria = new Criteria();
        }
        
        if ($this->collGl2Users === null) {
            if ($this->isNew()) {
               $this->collGl2Users = array();
            } else {
       
                $criteria->add(Gl2UserPeer::TIMEZONE_ID, $this->getTimezoneId());
                $this->collGl2Users = Gl2UserPeer::doSelectJoinGl2ListOfValuesRelatedByLocaleId($criteria, $con);
            }
        } else {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
      
            $criteria->add(Gl2UserPeer::TIMEZONE_ID, $this->getTimezoneId());
            if (!isset($this->lastGl2UsersCriteria) || !$this->lastGl2UsersCriteria->equals($criteria)) {
                $this->collGl2Users = Gl2UserPeer::doSelectJoinGl2ListOfValuesRelatedByLocaleId($criteria, $con);
            }
        }
        $this->lastGl2UsersCriteria = $criteria;

        return $this->collGl2Users;
    }



 
    /**
     * Removes this object from datastore and sets delete attribute.
     * 
     * @param Connection $con
     * @return void
     * @throws PropelException
     * @see BaseObject::setDeleted()
     * @see BaseObject::isDeleted()
     */
    public function delete($con = null)
    {    
        if ($this->isDeleted()) {
            throw new PropelException("This object has already been deleted.");
        }
        
        if ($con === null)
            $con = Propel::getConnection(Gl2TimezonePeer::DATABASE_NAME);

        try {
            $con->begin();
            Gl2TimezonePeer::doDelete($this, $con);
            $this->setDeleted(true);
            $con->commit();
        } catch (PropelException $e) {
            $con->rollback();
            throw $e;
        }
    }
    

    /**
     * flag to prevent endless save loop, if this object is referenced
     * by another object which falls in this transaction.
     * @var boolean
     */
    private $alreadyInSave = false;

    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.  This method
     * wraps the doSave() worker method in a transaction.
     *
     * @param Connection $con
     * @return void
     * @throws PropelException
     */
    public function save($con = null)
    {
        if ($this->isDeleted()) {
            throw new PropelException("You cannot save an object that has been deleted.");
        }
        
        if ($con === null)
            $con = Propel::getConnection(Gl2TimezonePeer::DATABASE_NAME);

        try {
            $con->begin();
            $this->doSave($con);            
            $con->commit();
        } catch (PropelException $e) {
            $con->rollback();
            throw $e;
        }
    }
  
    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     *
     * @param Connection $con
     * @return void
     * @throws PropelException
     */
		protected function doSave($con)    { 
        
     
        if (!$this->alreadyInSave) {
            $this->alreadyInSave = true;

            // If this object has been modified, then save it to the database.
            if ($this->isModified()) {
                if ($this->isNew()) {
                    $pk = Gl2TimezonePeer::doInsert($this, $con);
                    $this->setNew(false);
                } else {
                    Gl2TimezonePeer::doUpdate($this, $con);
                }            
                $this->resetModified(); // [HL] After being saved an object is no longer 'modified'
            }
            if ($this->collGl2Users !== null) {
                for ($i=0,$size=count($this->collGl2Users); $i < $size; $i++) {
                    $this->collGl2Users[$i]->save($con);
                }
              }

            $this->alreadyInSave = false;
        }
    }

    /**
     * Validates the objects modified field values.
     * This includes all objects related to this table.
     *
     * @return mixed <code>true</code> if all columns pass validation
     *              or an array of <code>ValidationFailed</code> objects for columns that fail.
     */
    public function validate()
    {
        return $this->doValidate();
    }

    /**
     * flag to prevent endless validation loop, if this object is referenced
     * by another object which falls in this transaction.
     * @var boolean
     */
    protected $alreadyInValidation = false;
  
    /**
     * This function performs the validation work for complex object models.
     * 
     * In addition to checking the current object, all related objects will
     * also be validated.  If all pass then <code>true</code> is returned; otherwise
     * an aggreagated array of ValidationFailed objects will be returned.
     *
     * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
     */
    protected function doValidate()
    {
        if (! $this->alreadyInValidation) {
            $this->alreadyInValidation = true;
            $retval = null;
      
            $failureMap = array();      

            if (($retval = Gl2TimezonePeer::doValidate($this)) !== true) {
                $failureMap = array_merge($failureMap, $retval);
            }
      
            if ($this->collGl2Users !== null) {
                for ($i=0,$size=count($this->collGl2Users); $i < $size; $i++) {
                    if (($retval = $this->collGl2Users[$i]->validate()) !== true) {
                        $failureMap = array_merge($failureMap, $retval);
                    }
                }
            }
      
            $this->alreadyInValidation = false;
        }
    
        return (!empty($failureMap) ? $failureMap : true);
    }
  

    /**
     * Set the PrimaryKey.
     *
     * @param mixed timezone_id Primary key.
     * @return void
     * @throws PropelException     */
    public function setPrimaryKey($key) 
    {        
        $this->setTimezoneId($key);
    }
    

    /**
     * Returns an id that differentiates this object from others
     * of its class.
     * @return int 
     */
    public function getPrimaryKey()
    {

        return $this->getTimezoneId();

    }

    
    /**
     * Makes a copy of this object that will be inserted as a new row in table when saved.
     * It creates a new object filling in the simple attributes, but skipping any primary
     * keys that are defined for the table.
     *  
     * If desired, this method can also make copies of all associated (fkey referrers)
     * objects.
     *
     * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
     *  
     * @return Gl2Timezone Clone of current object.
     * @throws PropelException
     */
    public function copy($deepCopy = false) 
    {
        $copyObj = new Gl2Timezone();
        $copyObj->setCode($this->code);
        $copyObj->setOffset($this->offset);
        $copyObj->setDescription($this->description);

        if ($deepCopy) {        
            // important: setNew(false) because this affects the behavior of
            // the getter/setter methods for fkey referrer objects.
            $copyObj->setNew(false);

            foreach($this->getGl2Users() as $relObj) {
                $copyObj->addGl2User($relObj->copy());
            }
        } // if ($deepCopy)
        
        $copyObj->setNew(true);
        
        $copyObj->setTimezoneId(NULL); // this is a pkey column, so set to default value

        return $copyObj;
    }
        

    /**
     * returns a peer instance associated with this om.  Since Peer classes    
     * are not to have any instance attributes, this method returns the
     * same instance for all member of this class. The method could therefore
     * be static, but this would prevent one from overriding the behavior.
     * @return Gl2TimezonePeer
     */
    public function getPeer()
    {
        if (self::$peer === null) {
            self::$peer = new Gl2TimezonePeer();
        }
        return self::$peer;
    }

}
--- NEW FILE: BaseGl2TimezonePeer.php ---
<?php
require_once 'propel/util/BasePeer.php';

// The object class -- needed for instanceof checks in this class.
// actual class may be a subclass -- as returned by Gl2TimezonePeer::getOMClass()
include_once 'Geeklog-2/Gl2Timezone.php';

/**
 * Base static class for performing query and update operations on the 'gl2_timezone' table.
 *
 *  *
 * This class was autogenerated by Propel on:
 *
 * [Mon Dec 20 15:25:53 2004]
 *
 * @package Geeklog-2 
 */
abstract class BaseGl2TimezonePeer
{

    /** the default database name for this class */
    const DATABASE_NAME = "Geeklog_2";

    /** the table name for this class */
    const TABLE_NAME = "gl2_timezone";

 
    /** the column name for the TIMEZONE_ID field */
    const TIMEZONE_ID = "gl2_timezone.TIMEZONE_ID";
 
    /** the column name for the CODE field */
    const CODE = "gl2_timezone.CODE";
 
    /** the column name for the OFFSET field */
    const OFFSET = "gl2_timezone.OFFSET";
 
    /** the column name for the DESCRIPTION field */
    const DESCRIPTION = "gl2_timezone.DESCRIPTION";

    

    /** number of columns for this peer */
    public static $numColumns = 4;
    
    /** A class that can be returned by this peer. */
    const CLASS_DEFAULT = "Geeklog-2.Gl2Timezone";

    /** The PHP to DB Name Mapping */
    private static $phpNameMap = null;

    /**
     * @return MapBuilder the map builder for this peer
     * @throws PropelException Any exceptions caught during processing will be
     *         rethrown wrapped into a PropelException.
     */
    public static function getMapBuilder()        
    {
        include_once 'Geeklog-2/map/Gl2TimezoneMapBuilder.php';
        return BasePeer::getMapBuilder(Gl2TimezoneMapBuilder::CLASS_NAME);
    }

    /**
     * Gets a map (hash) of PHP names to DB column names.
     *
     * @return array The PHP to DB name map for this peer
     * @throws PropelException Any exceptions caught during processing will be
     *         rethrown wrapped into a PropelException.
     * @todo Consider having template build the array rather than doing it at runtime.
     */
    public static function getPhpNameMap()
    {
        if (self::$phpNameMap === null) {
            $map = Gl2TimezonePeer::getTableMap();
            $columns = $map->getColumns();
            $nameMap = array();
            foreach ($columns as $column) {
                $nameMap[$column->getPhpName()] = $column->getColumnName();
            }
            self::$phpNameMap = $nameMap;
        }
        return self::$phpNameMap;
    }
    
    /**
     * Convenience method which changes table.column to alias.column.
     *
     * Using this method you can maintain SQL abstraction while using column aliases.
     * <code>
     *        $c->addAlias("alias1", TablePeer::TABLE_NAME);
     *        $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
     * </code>
     * @param string $alias The alias for the current table.
     * @param string $column The column name for current table. (i.e. Gl2TimezonePeer::COLUMN_NAME).
     * @return string
     */
    public static function alias($alias, $column)
    {
        return $alias . substr($column, strlen(self::TABLE_NAME));
    }
    
    /**
     * Add all the columns needed to create a new object.
     * 
     * Note: any columns that were marked with lazyLoad="true" in the
     * XML schema will not be added to the select list and only loaded
     * on demand.
     *
     * @param criteria object containing the columns to add.
     * @throws PropelException Any exceptions caught during processing will be
     *         rethrown wrapped into a PropelException.
     */
    public static function addSelectColumns(Criteria $criteria)
    {
        $criteria->addSelectColumn(self::TIMEZONE_ID);
        $criteria->addSelectColumn(self::CODE);
        $criteria->addSelectColumn(self::OFFSET);
        $criteria->addSelectColumn(self::DESCRIPTION);
    }

    /**
     * Populates an object from a resultset row starting
     * from a specified start column.  This is done so that you can select
     * other rows than just those needed for this object.  You may
     * for example want to create two objects from the same row.
     *
     * @param ResultSet $rs The ResultSet to use for setting values.
     * @param Gl2Timezone $obj The object to populate.
     * @param int $startcol The column to start with (1 is first column).     
     * @return void
     * @throws PropelException Any exceptions caught during processing will be
     *         rethrown wrapped into a PropelException.
     * @deprecated This method has been deprecated in favor of the more flexible
     *              Gl2Timezone->hydrate() method.
     *              This method is planned for removal in Propel 1.1.
     * @see Gl2Timezone::hydrate()
     */
    public static function populateObject(ResultSet $rs,Gl2Timezone $obj, $startcol = 1)
    {        
        $obj->hydrate($rs, $startcol);        
    }
    
    const COUNT = "COUNT(gl2_timezone.TIMEZONE_ID)";
    const COUNT_DISTINCT = "COUNT(DISTINCT gl2_timezone.TIMEZONE_ID)";
  
    /**
     * Returns the number of rows matching criteria.
     *
     * @param Criteria $criteria
     * @param boolean $distinct Whether to select only distinct columns.
     * @param Connection $con
     * @return int Number of matching rows.
     */
    function doCount(Criteria $criteria, $distinct = false, $con = null)
    {   
        // we're going to modify criteria, so copy it first
        $criteria = clone $criteria;
        
        // clear out anything that might confuse the ORDER BY clause
        $criteria->clearSelectColumns()->clearOrderByColumns();
        if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
            $criteria->addSelectColumn(Gl2TimezonePeer::COUNT_DISTINCT);
        } else {
            $criteria->addSelectColumn(Gl2TimezonePeer::COUNT);    
        }
        
        $rs = Gl2TimezonePeer::doSelectRS($criteria, $con);        
        if ($rs->next()) {
            return $rs->getInt(1);
        } else {
            // no rows returned; we infer that means 0 matches.
            return 0;
        }
    }
  
    /**
     * Method to select one object from the DB.
     *
     * @param Criteria $criteria object used to create the SELECT statement.
     * @param Connection $con
     * @return Gl2Timezone     * @throws PropelException Any exceptions caught during processing will be
     *         rethrown wrapped into a PropelException.
     */
    public static function doSelectOne(Criteria $criteria, $con = null)
    {
        $critcopy = clone $criteria;
        $critcopy->setLimit(1);
        $objects = Gl2TimezonePeer::doSelect($critcopy, $con);
        if ($objects) {
            return $objects[0];
        }
        return null;
    }

    /**
     * Method to do selects.
     *
     * @param Criteria $criteria The Criteria object used to build the SELECT statement.
     * @param Connection $con
     * @return array Array of selected Objects
     * @throws PropelException Any exceptions caught during processing will be
     *         rethrown wrapped into a PropelException.
     */
    public static function doSelect(Criteria $criteria, $con = null)
    {
        return Gl2TimezonePeer::populateObjects(Gl2TimezonePeer::doSelectRS($criteria, $con));
    }
    
    /**
     * Prepares the Criteria object and uses the parent doSelect()
     * method to get a ResultSet.
     * 
     * Use this method directly if you want to just get the resultset
     * (instead of an array of objects).
     *
     * @param Criteria $criteria The Criteria object used to build the SELECT statement.
     * @param Connection $con the connection to use
     * @throws PropelException Any exceptions caught during processing will be
     *         rethrown wrapped into a PropelException.
     * @return ResultSet The resultset object with numerically-indexed fields.
     * @see BasePeer::doSelect()
     */
    public static function doSelectRS(Criteria $criteria, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection(self::DATABASE_NAME);
        }                

        if (!$criteria->getSelectColumns()) {
            Gl2TimezonePeer::addSelectColumns($criteria);
        }
    
        // Set the correct dbName
        $criteria->setDbName(self::DATABASE_NAME);
        
        // BasePeer returns a Creole ResultSet, set to return
        // rows indexed numerically.           
        return BasePeer::doSelect($criteria, $con);
    }

    /**
     * The returned array will contain objects of the default type or
     * objects that inherit from the default.
     *
     * @throws PropelException Any exceptions caught during processing will be
     *         rethrown wrapped into a PropelException.
     */
    public static function populateObjects(ResultSet $rs)
    {
        $results = array();
        
        // set the class once to avoid overhead in the loop
        $cls = Gl2TimezonePeer::getOMClass();
        $cls = Propel::import($cls);

        // populate the object(s)
        while($rs->next()) {
            
            $obj = new $cls();
            $obj->hydrate($rs);
            $results[] = $obj;
        }
        return $results;
    }



    /**
     * The class that the Peer will make instances of.
     * If the BO is abstract then you must implement this method
     * in the BO.
     *
     * @throws PropelException Any exceptions caught during processing will be
     *         rethrown wrapped into a PropelException.
     */
    public static function getOMClass()
    { 
        return self::CLASS_DEFAULT;
         
    }
 

    /**
     * Method perform an INSERT on the database, given a Gl2Timezone or Criteria object.
     *
     * @param mixed $values Criteria or Gl2Timezone object containing data that is used to create the INSERT statement.
     * @param Connection $con the connection to use
     * @return mixed The new primary key.
     * @throws PropelException Any exceptions caught during processing will be
     *         rethrown wrapped into a PropelException.
     */
    public static function doInsert($values, $con = null)
    {        
        if ($con === null)
            $con = Propel::getConnection(self::DATABASE_NAME);

        if ($values instanceof Criteria) {
            $criteria = $values;
        } else {
            $criteria = $values->buildCriteria();
        }
        
 
        
        // Set the correct dbName
        $criteria->setDbName(self::DATABASE_NAME);
        
        try {
            // use transaction because $criteria could contain info
            // for more than one table (I guess, conceivably)
            $con->begin();
            $pk = BasePeer::doInsert($criteria, $con);
            $con->commit();
        } catch(PropelException $e) {
            $con->rollback();
            throw $e;
        }
        
        return $pk;        
    }

    /**
     * Method perform an UPDATE on the database, given a Gl2Timezone or Criteria object.
     *
     * @param mixed $values Criteria or Gl2Timezone object containing data that is used to create the UPDATE statement.
     * @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
     * @return void
     * @throws PropelException Any exceptions caught during processing will be
     *         rethrown wrapped into a PropelException.
     */
    public static function doUpdate($values, $con = null)
    {            
        if ($con === null) {
            $con = Propel::getConnection(self::DATABASE_NAME);
        }
        
        $selectCriteria = new Criteria(self::DATABASE_NAME);
                
        if ($values instanceof Criteria) {
            $criteria = $values;
            $selectCriteria->put(self::TIMEZONE_ID, $criteria->remove(self::TIMEZONE_ID));
 
        } else { // $values is Gl2Timezone object
            $criteria = $values->buildCriteria(); // gets full criteria
            $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)            
        }    
        
        // set the correct dbName
        $criteria->setDbName(self::DATABASE_NAME);
        
        BasePeer::doUpdate($selectCriteria, $criteria, $con);        
    }   
    
    /**
     * Method perform a DELETE on the database, given a Gl2Timezone or Criteria object OR a primary key value.
     *
     * @param mixed $values Criteria or Gl2Timezone object or primary key which is used to create the DELETE statement 
     * @param Connection $con the connection to use
     * @return void
     * @throws PropelException Any exceptions caught during processing will be
     *         rethrown wrapped into a PropelException.
     */
     public static function doDelete($values, $con = null)
     {        
        if ($con === null)
            $con = Propel::getConnection(self::DATABASE_NAME);

        if ($values instanceof Criteria) {
            $criteria = $values;
        } elseif ($values instanceof Gl2Timezone) {
            $criteria = $values->buildPkeyCriteria();
        } else {
            // it must be the primary key
            $criteria = new Criteria(self::DATABASE_NAME);
            $criteria->add(self::TIMEZONE_ID, $values);
        }
             
        // Set the correct dbName
        $criteria->setDbName(self::DATABASE_NAME);
        
        try {
            // use transaction because $criteria could contain info
            // for more than one table or we could emulating ON DELETE CASCADE, etc.
            $con->begin();
             
            BasePeer::doDelete($criteria, $con);
            $con->commit();
        } catch (PropelException $e) {
            $con->rollback();
            throw $e;
        }        
    }    

    
    /**
     * Validates all modified columns of given Gl2Timezone object.
     *
     * NOTICE: This does not apply to primary or foreign keys for now.
     *
     * @param Gl2Timezone $obj The object to validate.
     * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
     */
    public static function doValidate(Gl2Timezone $obj)
    {        
        $columns = array();
        return BasePeer::doValidate(self::DATABASE_NAME, self::TABLE_NAME, $columns);
    }
      


    /**
     * Retrieve a single object by pkey.
     *
     * @param mixed $pk the primary key.
     * @param Connection $con the connection to use
     * @throws PropelException Any exceptions caught during processing will be
     *         rethrown wrapped into a PropelException.
     */
    public static function retrieveByPK($pk, $con = null)
    {        
        if ($con === null) {
            $con = Propel::getConnection(self::DATABASE_NAME);
        }
        
        $criteria = new Criteria(self::DATABASE_NAME);
        $criteria->add(self::TIMEZONE_ID, $pk);
                        
        $v = Gl2TimezonePeer::doSelect($criteria, $con);
        if (count($v) !== 1) {
            throw new PropelException("Failed to select one and only one row.");
        } else {
            return $v[0];
        }
    }

    /**
     * Retrieve multiple objects by pkey.
     *
     * @param array $pks List of primary keys
     * @param Connection $con the connection to use
     * @throws PropelException Any exceptions caught during processing will be
     *         rethrown wrapped into a PropelException.
     */
    public static function retrieveByPKs($pks, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection(self::DATABASE_NAME);
        }
        
        $objs = null;
        if (empty($pks)) {
            $objs = array();
        } else {
            $criteria = new Criteria();
            $criteria->add(self::TIMEZONE_ID, $pks, Criteria::IN);
  
            $objs = Gl2TimezonePeer::doSelect($criteria, $con);
        }
        return $objs;
    }

 

    /**
     * Returns the TableMap related to this peer.  This method is not
     * needed for general use but a specific application could have a need.
     * @return TableMap
     * @throws PropelException Any exceptions caught during processing will be
     *         rethrown wrapped into a PropelException.
     */
    protected static function getTableMap()
    {
        return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
    }
    
}

// static code to register the map builder for this Peer with the main Propel class
if (Propel::isInit()) {
    // the MapBuilder classes register themselves with Propel during initialization
    // so we need to load them here.
    try {        
        BaseGl2TimezonePeer::getMapBuilder();
    } catch (Exception $e) {
        Propel::logger()->err("Could not initialize Peer: " . $e->getMessage());
    }
} else {
    // even if Propel is not yet initialized, the map builder class can be registered
    // now and then it will be loaded when Propel initializes.
    require_once 'Geeklog-2/map/Gl2TimezoneMapBuilder.php';
    Propel::registerMapBuilder(Gl2TimezoneMapBuilder::CLASS_NAME);
}



More information about the geeklog-cvs mailing list