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

Source for file BaseEtvaAgent.php

Documentation is available at BaseEtvaAgent.php

  1. <?php
  2.  
  3. /**
  4.  * Base class that represents a row from 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 BaseEtvaAgent extends BaseObject  implements Persistent {
  15.  
  16.  
  17.   const PEER = 'EtvaAgentPeer';
  18.  
  19.     /**
  20.      * The Peer class.
  21.      * Instance provides a convenient way of calling static methods on a class
  22.      * that calling code may not be able to identify.
  23.      * @var        EtvaAgentPeer 
  24.      */
  25.     protected static $peer;
  26.  
  27.     /**
  28.      * The value for the id field.
  29.      * @var        int 
  30.      */
  31.     protected $id;
  32.  
  33.     /**
  34.      * The value for the server_id field.
  35.      * @var        int 
  36.      */
  37.     protected $server_id;
  38.  
  39.     /**
  40.      * The value for the name field.
  41.      * @var        string 
  42.      */
  43.     protected $name;
  44.  
  45.     /**
  46.      * The value for the description field.
  47.      * @var        string 
  48.      */
  49.     protected $description;
  50.  
  51.     /**
  52.      * The value for the service field.
  53.      * @var        string 
  54.      */
  55.     protected $service;
  56.  
  57.     /**
  58.      * The value for the ip field.
  59.      * @var        string 
  60.      */
  61.     protected $ip;
  62.  
  63.     /**
  64.      * The value for the state field.
  65.      * Note: this column has a database default value of: 1
  66.      * @var        int 
  67.      */
  68.     protected $state;
  69.  
  70.     /**
  71.      * The value for the created_at field.
  72.      * @var        string 
  73.      */
  74.     protected $created_at;
  75.  
  76.     /**
  77.      * The value for the updated_at field.
  78.      * @var        string 
  79.      */
  80.     protected $updated_at;
  81.  
  82.     /**
  83.      * @var        EtvaServer 
  84.      */
  85.     protected $aEtvaServer;
  86.  
  87.     /**
  88.      * Flag to prevent endless save loop, if this object is referenced
  89.      * by another object which falls in this transaction.
  90.      * @var        boolean 
  91.      */
  92.     protected $alreadyInSave = false;
  93.  
  94.     /**
  95.      * Flag to prevent endless validation loop, if this object is referenced
  96.      * by another object which falls in this transaction.
  97.      * @var        boolean 
  98.      */
  99.     protected $alreadyInValidation = false;
  100.  
  101.     /**
  102.      * Initializes internal state of BaseEtvaAgent object.
  103.      * @see        applyDefaults()
  104.      */
  105.     public function __construct()
  106.     {
  107.         parent::__construct();
  108.         $this->applyDefaultValues();
  109.     }
  110.  
  111.     /**
  112.      * Applies default values to this object.
  113.      * This method should be called from the object's constructor (or
  114.      * equivalent initialization method).
  115.      * @see        __construct()
  116.      */
  117.     public function applyDefaultValues()
  118.     {
  119.         $this->state = 1;
  120.     }
  121.  
  122.     /**
  123.      * Get the [id] column value.
  124.      * 
  125.      * @return     int 
  126.      */
  127.     public function getId()
  128.     {
  129.         return $this->id;
  130.     }
  131.  
  132.     /**
  133.      * Get the [server_id] column value.
  134.      * 
  135.      * @return     int 
  136.      */
  137.     public function getServerId()
  138.     {
  139.         return $this->server_id;
  140.     }
  141.  
  142.     /**
  143.      * Get the [name] column value.
  144.      * 
  145.      * @return     string 
  146.      */
  147.     public function getName()
  148.     {
  149.         return $this->name;
  150.     }
  151.  
  152.     /**
  153.      * Get the [description] column value.
  154.      * 
  155.      * @return     string 
  156.      */
  157.     public function getDescription()
  158.     {
  159.         return $this->description;
  160.     }
  161.  
  162.     /**
  163.      * Get the [service] column value.
  164.      * 
  165.      * @return     string 
  166.      */
  167.     public function getService()
  168.     {
  169.         return $this->service;
  170.     }
  171.  
  172.     /**
  173.      * Get the [ip] column value.
  174.      * 
  175.      * @return     string 
  176.      */
  177.     public function getIp()
  178.     {
  179.         return $this->ip;
  180.     }
  181.  
  182.     /**
  183.      * Get the [state] column value.
  184.      * 
  185.      * @return     int 
  186.      */
  187.     public function getState()
  188.     {
  189.         return $this->state;
  190.     }
  191.  
  192.     /**
  193.      * Get the [optionally formatted] temporal [created_at] column value.
  194.      * 
  195.      *
  196.      * @param      string $format The date/time format string (either date()-style or strftime()-style).
  197.      *                             If format is NULL, then the raw DateTime object will be returned.
  198.      * @return     mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
  199.      * @throws     PropelException - if unable to parse/validate the date/time value.
  200.      */
  201.     public function getCreatedAt($format 'Y-m-d H:i:s')
  202.     {
  203.         if ($this->created_at === null{
  204.             return null;
  205.         }
  206.  
  207.  
  208.  
  209.         try {
  210.             $dt new DateTime($this->created_at);
  211.         catch (Exception $x{
  212.             throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " var_export($this->created_attrue)$x);
  213.         }
  214.  
  215.         if ($format === null{
  216.             // Because propel.useDateTimeClass is TRUE, we return a DateTime object.
  217.             return $dt;
  218.         elseif (strpos($format'%'!== false{
  219.             return strftime($format$dt->format('U'));
  220.         else {
  221.             return $dt->format($format);
  222.         }
  223.     }
  224.  
  225.     /**
  226.      * Get the [optionally formatted] temporal [updated_at] column value.
  227.      * 
  228.      *
  229.      * @param      string $format The date/time format string (either date()-style or strftime()-style).
  230.      *                             If format is NULL, then the raw DateTime object will be returned.
  231.      * @return     mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
  232.      * @throws     PropelException - if unable to parse/validate the date/time value.
  233.      */
  234.     public function getUpdatedAt($format 'Y-m-d H:i:s')
  235.     {
  236.         if ($this->updated_at === null{
  237.             return null;
  238.         }
  239.  
  240.  
  241.  
  242.         try {
  243.             $dt new DateTime($this->updated_at);
  244.         catch (Exception $x{
  245.             throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " var_export($this->updated_attrue)$x);
  246.         }
  247.  
  248.         if ($format === null{
  249.             // Because propel.useDateTimeClass is TRUE, we return a DateTime object.
  250.             return $dt;
  251.         elseif (strpos($format'%'!== false{
  252.             return strftime($format$dt->format('U'));
  253.         else {
  254.             return $dt->format($format);
  255.         }
  256.     }
  257.  
  258.     /**
  259.      * Set the value of [id] column.
  260.      * 
  261.      * @param      int $v new value
  262.      * @return     EtvaAgent The current object (for fluent API support)
  263.      */
  264.     public function setId($v)
  265.     {
  266.         if ($v !== null{
  267.             $v = (int) $v;
  268.         }
  269.  
  270.         if ($this->id !== $v{
  271.             $this->id = $v;
  272.             $this->modifiedColumns[EtvaAgentPeer::ID;
  273.         }
  274.  
  275.         return $this;
  276.     // setId()
  277.  
  278.     /**
  279.      * Set the value of [server_id] column.
  280.      * 
  281.      * @param      int $v new value
  282.      * @return     EtvaAgent The current object (for fluent API support)
  283.      */
  284.     public function setServerId($v)
  285.     {
  286.         if ($v !== null{
  287.             $v = (int) $v;
  288.         }
  289.  
  290.         if ($this->server_id !== $v{
  291.             $this->server_id = $v;
  292.             $this->modifiedColumns[EtvaAgentPeer::SERVER_ID;
  293.         }
  294.  
  295.         if ($this->aEtvaServer !== null && $this->aEtvaServer->getId(!== $v{
  296.             $this->aEtvaServer = null;
  297.         }
  298.  
  299.         return $this;
  300.     // setServerId()
  301.  
  302.     /**
  303.      * Set the value of [name] column.
  304.      * 
  305.      * @param      string $v new value
  306.      * @return     EtvaAgent The current object (for fluent API support)
  307.      */
  308.     public function setName($v)
  309.     {
  310.         if ($v !== null{
  311.             $v = (string) $v;
  312.         }
  313.  
  314.         if ($this->name !== $v{
  315.             $this->name = $v;
  316.             $this->modifiedColumns[EtvaAgentPeer::NAME;
  317.         }
  318.  
  319.         return $this;
  320.     // setName()
  321.  
  322.     /**
  323.      * Set the value of [description] column.
  324.      * 
  325.      * @param      string $v new value
  326.      * @return     EtvaAgent The current object (for fluent API support)
  327.      */
  328.     public function setDescription($v)
  329.     {
  330.         if ($v !== null{
  331.             $v = (string) $v;
  332.         }
  333.  
  334.         if ($this->description !== $v{
  335.             $this->description = $v;
  336.             $this->modifiedColumns[EtvaAgentPeer::DESCRIPTION;
  337.         }
  338.  
  339.         return $this;
  340.     // setDescription()
  341.  
  342.     /**
  343.      * Set the value of [service] column.
  344.      * 
  345.      * @param      string $v new value
  346.      * @return     EtvaAgent The current object (for fluent API support)
  347.      */
  348.     public function setService($v)
  349.     {
  350.         if ($v !== null{
  351.             $v = (string) $v;
  352.         }
  353.  
  354.         if ($this->service !== $v{
  355.             $this->service = $v;
  356.             $this->modifiedColumns[EtvaAgentPeer::SERVICE;
  357.         }
  358.  
  359.         return $this;
  360.     // setService()
  361.  
  362.     /**
  363.      * Set the value of [ip] column.
  364.      * 
  365.      * @param      string $v new value
  366.      * @return     EtvaAgent The current object (for fluent API support)
  367.      */
  368.     public function setIp($v)
  369.     {
  370.         if ($v !== null{
  371.             $v = (string) $v;
  372.         }
  373.  
  374.         if ($this->ip !== $v{
  375.             $this->ip = $v;
  376.             $this->modifiedColumns[EtvaAgentPeer::IP;
  377.         }
  378.  
  379.         return $this;
  380.     // setIp()
  381.  
  382.     /**
  383.      * Set the value of [state] column.
  384.      * 
  385.      * @param      int $v new value
  386.      * @return     EtvaAgent The current object (for fluent API support)
  387.      */
  388.     public function setState($v)
  389.     {
  390.         if ($v !== null{
  391.             $v = (int) $v;
  392.         }
  393.  
  394.         if ($this->state !== $v || $v === 1{
  395.             $this->state = $v;
  396.             $this->modifiedColumns[EtvaAgentPeer::STATE;
  397.         }
  398.  
  399.         return $this;
  400.     // setState()
  401.  
  402.     /**
  403.      * Sets the value of [created_at] column to a normalized version of the date/time value specified.
  404.      * 
  405.      * @param      mixed $v string, integer (timestamp), or DateTime value.  Empty string will
  406.      *                         be treated as NULL for temporal objects.
  407.      * @return     EtvaAgent The current object (for fluent API support)
  408.      */
  409.     public function setCreatedAt($v)
  410.     {
  411.         // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
  412.         // -- which is unexpected, to say the least.
  413.         if ($v === null || $v === ''{
  414.             $dt null;
  415.         elseif ($v instanceof DateTime{
  416.             $dt $v;
  417.         else {
  418.             // some string/numeric value passed; we normalize that so that we can
  419.             // validate it.
  420.             try {
  421.                 if (is_numeric($v)) // if it's a unix timestamp
  422.                     $dt new DateTime('@'.$vnew DateTimeZone('UTC'));
  423.                     // We have to explicitly specify and then change the time zone because of a
  424.                     // DateTime bug: http://bugs.php.net/bug.php?id=43003
  425.                     $dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
  426.                 else {
  427.                     $dt new DateTime($v);
  428.                 }
  429.             catch (Exception $x{
  430.                 throw new PropelException('Error parsing date/time value: ' var_export($vtrue)$x);
  431.             }
  432.         }
  433.  
  434.         if $this->created_at !== null || $dt !== null {
  435.             // (nested ifs are a little easier to read in this case)
  436.  
  437.             $currNorm ($this->created_at !== null && $tmpDt new DateTime($this->created_at)) $tmpDt->format('Y-m-d\\TH:i:sO'null;
  438.             $newNorm ($dt !== null$dt->format('Y-m-d\\TH:i:sO'null;
  439.  
  440.             if ( ($currNorm !== $newNorm// normalized values don't match 
  441.                     )
  442.             {
  443.                 $this->created_at = ($dt $dt->format('Y-m-d\\TH:i:sO'null);
  444.                 $this->modifiedColumns[EtvaAgentPeer::CREATED_AT;
  445.             }
  446.         // if either are not null
  447.  
  448.         return $this;
  449.     // setCreatedAt()
  450.  
  451.     /**
  452.      * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
  453.      * 
  454.      * @param      mixed $v string, integer (timestamp), or DateTime value.  Empty string will
  455.      *                         be treated as NULL for temporal objects.
  456.      * @return     EtvaAgent The current object (for fluent API support)
  457.      */
  458.     public function setUpdatedAt($v)
  459.     {
  460.         // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
  461.         // -- which is unexpected, to say the least.
  462.         if ($v === null || $v === ''{
  463.             $dt null;
  464.         elseif ($v instanceof DateTime{
  465.             $dt $v;
  466.         else {
  467.             // some string/numeric value passed; we normalize that so that we can
  468.             // validate it.
  469.             try {
  470.                 if (is_numeric($v)) // if it's a unix timestamp
  471.                     $dt new DateTime('@'.$vnew DateTimeZone('UTC'));
  472.                     // We have to explicitly specify and then change the time zone because of a
  473.                     // DateTime bug: http://bugs.php.net/bug.php?id=43003
  474.                     $dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
  475.                 else {
  476.                     $dt new DateTime($v);
  477.                 }
  478.             catch (Exception $x{
  479.                 throw new PropelException('Error parsing date/time value: ' var_export($vtrue)$x);
  480.             }
  481.         }
  482.  
  483.         if $this->updated_at !== null || $dt !== null {
  484.             // (nested ifs are a little easier to read in this case)
  485.  
  486.             $currNorm ($this->updated_at !== null && $tmpDt new DateTime($this->updated_at)) $tmpDt->format('Y-m-d\\TH:i:sO'null;
  487.             $newNorm ($dt !== null$dt->format('Y-m-d\\TH:i:sO'null;
  488.  
  489.             if ( ($currNorm !== $newNorm// normalized values don't match 
  490.                     )
  491.             {
  492.                 $this->updated_at = ($dt $dt->format('Y-m-d\\TH:i:sO'null);
  493.                 $this->modifiedColumns[EtvaAgentPeer::UPDATED_AT;
  494.             }
  495.         // if either are not null
  496.  
  497.         return $this;
  498.     // setUpdatedAt()
  499.  
  500.     /**
  501.      * Indicates whether the columns in this object are only set to default values.
  502.      *
  503.      * This method can be used in conjunction with isModified() to indicate whether an object is both
  504.      * modified _and_ has some values set which are non-default.
  505.      *
  506.      * @return     boolean Whether the columns in this object are only been set with default values.
  507.      */
  508.     public function hasOnlyDefaultValues()
  509.     {
  510.             // First, ensure that we don't have any columns that have been modified which aren't default columns.
  511.             if (array_diff($this->modifiedColumnsarray(EtvaAgentPeer::STATE))) {
  512.                 return false;
  513.             }
  514.  
  515.             if ($this->state !== 1{
  516.                 return false;
  517.             }
  518.  
  519.         // otherwise, everything was equal, so return TRUE
  520.         return true;
  521.     // hasOnlyDefaultValues()
  522.  
  523.     /**
  524.      * Hydrates (populates) the object variables with values from the database resultset.
  525.      *
  526.      * An offset (0-based "start column") is specified so that objects can be hydrated
  527.      * with a subset of the columns in the resultset rows.  This is needed, for example,
  528.      * for results of JOIN queries where the resultset row includes columns from two or
  529.      * more tables.
  530.      *
  531.      * @param      array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
  532.      * @param      int $startcol 0-based offset column which indicates which restultset column to start with.
  533.      * @param      boolean $rehydrate Whether this object is being re-hydrated from the database.
  534.      * @return     int next starting column
  535.      * @throws     PropelException  - Any caught Exception will be rewrapped as a PropelException.
  536.      */
  537.     public function hydrate($row$startcol 0$rehydrate false)
  538.     {
  539.         try {
  540.  
  541.             $this->id = ($row[$startcol 0!== null? (int) $row[$startcol 0null;
  542.             $this->server_id = ($row[$startcol 1!== null? (int) $row[$startcol 1null;
  543.             $this->name = ($row[$startcol 2!== null? (string) $row[$startcol 2null;
  544.             $this->description = ($row[$startcol 3!== null? (string) $row[$startcol 3null;
  545.             $this->service = ($row[$startcol 4!== null? (string) $row[$startcol 4null;
  546.             $this->ip = ($row[$startcol 5!== null? (string) $row[$startcol 5null;
  547.             $this->state = ($row[$startcol 6!== null? (int) $row[$startcol 6null;
  548.             $this->created_at = ($row[$startcol 7!== null? (string) $row[$startcol 7null;
  549.             $this->updated_at = ($row[$startcol 8!== null? (string) $row[$startcol 8null;
  550.             $this->resetModified();
  551.  
  552.             $this->setNew(false);
  553.  
  554.             if ($rehydrate{
  555.                 $this->ensureConsistency();
  556.             }
  557.  
  558.             // FIXME - using NUM_COLUMNS may be clearer.
  559.             return $startcol 9// 9 = EtvaAgentPeer::NUM_COLUMNS - EtvaAgentPeer::NUM_LAZY_LOAD_COLUMNS).
  560.  
  561.         catch (Exception $e{
  562.             throw new PropelException("Error populating EtvaAgent object"$e);
  563.         }
  564.     }
  565.  
  566.     /**
  567.      * Checks and repairs the internal consistency of the object.
  568.      *
  569.      * This method is executed after an already-instantiated object is re-hydrated
  570.      * from the database.  It exists to check any foreign keys to make sure that
  571.      * the objects related to the current object are correct based on foreign key.
  572.      *
  573.      * You can override this method in the stub class, but you should always invoke
  574.      * the base method from the overridden method (i.e. parent::ensureConsistency()),
  575.      * in case your model changes.
  576.      *
  577.      * @throws     PropelException
  578.      */
  579.     public function ensureConsistency()
  580.     {
  581.  
  582.         if ($this->aEtvaServer !== null && $this->server_id !== $this->aEtvaServer->getId()) {
  583.             $this->aEtvaServer = null;
  584.         }
  585.     // ensureConsistency
  586.  
  587.     /**
  588.      * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
  589.      *
  590.      * This will only work if the object has been saved and has a valid primary key set.
  591.      *
  592.      * @param      boolean $deep (optional) Whether to also de-associated any related objects.
  593.      * @param      PropelPDO $con (optional) The PropelPDO connection to use.
  594.      * @return     void 
  595.      * @throws     PropelException - if this object is deleted, unsaved or doesn't have pk match in db
  596.      */
  597.     public function reload($deep falsePropelPDO $con null)
  598.     {
  599.         if ($this->isDeleted()) {
  600.             throw new PropelException("Cannot reload a deleted object.");
  601.         }
  602.  
  603.         if ($this->isNew()) {
  604.             throw new PropelException("Cannot reload an unsaved object.");
  605.         }
  606.  
  607.         if ($con === null{
  608.             $con Propel::getConnection(EtvaAgentPeer::DATABASE_NAMEPropel::CONNECTION_READ);
  609.         }
  610.  
  611.         // We don't need to alter the object instance pool; we're just modifying this instance
  612.         // already in the pool.
  613.  
  614.         $stmt EtvaAgentPeer::doSelectStmt($this->buildPkeyCriteria()$con);
  615.         $row $stmt->fetch(PDO::FETCH_NUM);
  616.         $stmt->closeCursor();
  617.         if (!$row{
  618.             throw new PropelException('Cannot find matching row in the database to reload object values.');
  619.         }
  620.         $this->hydrate($row0true)// rehydrate
  621.  
  622.         if ($deep{  // also de-associate any related objects?
  623.  
  624.             $this->aEtvaServer = null;
  625.         // if (deep)
  626.     }
  627.  
  628.     /**
  629.      * Removes this object from datastore and sets delete attribute.
  630.      *
  631.      * @param      PropelPDO $con 
  632.      * @return     void 
  633.      * @throws     PropelException
  634.      * @see        BaseObject::setDeleted()
  635.      * @see        BaseObject::isDeleted()
  636.      */
  637.     public function delete(PropelPDO $con null)
  638.     {
  639.  
  640.     foreach (sfMixer::getCallables('BaseEtvaAgent:delete:pre'as $callable)
  641.     {
  642.       $ret call_user_func($callable$this$con);
  643.       if ($ret)
  644.       {
  645.         return;
  646.       }
  647.     }
  648.  
  649.  
  650.         if ($this->isDeleted()) {
  651.             throw new PropelException("This object has already been deleted.");
  652.         }
  653.  
  654.         if ($con === null{
  655.             $con Propel::getConnection(EtvaAgentPeer::DATABASE_NAMEPropel::CONNECTION_WRITE);
  656.         }
  657.         
  658.         $con->beginTransaction();
  659.         try {
  660.             EtvaAgentPeer::doDelete($this$con);
  661.             $this->setDeleted(true);
  662.             $con->commit();
  663.         catch (PropelException $e{
  664.             $con->rollBack();
  665.             throw $e;
  666.         }
  667.     
  668.  
  669.     foreach (sfMixer::getCallables('BaseEtvaAgent:delete:post'as $callable)
  670.     {
  671.       call_user_func($callable$this$con);
  672.     }
  673.  
  674.   }
  675.     /**
  676.      * Persists this object to the database.
  677.      *
  678.      * If the object is new, it inserts it; otherwise an update is performed.
  679.      * All modified related objects will also be persisted in the doSave()
  680.      * method.  This method wraps all precipitate database operations in a
  681.      * single transaction.
  682.      *
  683.      * @param      PropelPDO $con 
  684.      * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  685.      * @throws     PropelException
  686.      * @see        doSave()
  687.      */
  688.     public function save(PropelPDO $con null)
  689.     {
  690.  
  691.     foreach (sfMixer::getCallables('BaseEtvaAgent:save:pre'as $callable)
  692.     {
  693.       $affectedRows call_user_func($callable$this$con);
  694.       if (is_int($affectedRows))
  695.       {
  696.         return $affectedRows;
  697.       }
  698.     }
  699.  
  700.  
  701.     if ($this->isNew(&& !$this->isColumnModified(EtvaAgentPeer::CREATED_AT))
  702.     {
  703.       $this->setCreatedAt(time());
  704.     }
  705.  
  706.     if ($this->isModified(&& !$this->isColumnModified(EtvaAgentPeer::UPDATED_AT))
  707.     {
  708.       $this->setUpdatedAt(time());
  709.     }
  710.  
  711.         if ($this->isDeleted()) {
  712.             throw new PropelException("You cannot save an object that has been deleted.");
  713.         }
  714.  
  715.         if ($con === null{
  716.             $con Propel::getConnection(EtvaAgentPeer::DATABASE_NAMEPropel::CONNECTION_WRITE);
  717.         }
  718.         
  719.         $con->beginTransaction();
  720.         try {
  721.             $affectedRows $this->doSave($con);
  722.             $con->commit();
  723.     foreach (sfMixer::getCallables('BaseEtvaAgent:save:post'as $callable)
  724.     {
  725.       call_user_func($callable$this$con$affectedRows);
  726.     }
  727.  
  728.             EtvaAgentPeer::addInstanceToPool($this);
  729.             return $affectedRows;
  730.         catch (PropelException $e{
  731.             $con->rollBack();
  732.             throw $e;
  733.         }
  734.     }
  735.  
  736.     /**
  737.      * Performs the work of inserting or updating the row in the database.
  738.      *
  739.      * If the object is new, it inserts it; otherwise an update is performed.
  740.      * All related objects are also updated in this method.
  741.      *
  742.      * @param      PropelPDO $con 
  743.      * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  744.      * @throws     PropelException
  745.      * @see        save()
  746.      */
  747.     protected function doSave(PropelPDO $con)
  748.     {
  749.         $affectedRows 0// initialize var to track total num of affected rows
  750.         if (!$this->alreadyInSave{
  751.             $this->alreadyInSave = true;
  752.  
  753.             // We call the save method on the following object(s) if they
  754.             // were passed to this object by their coresponding set
  755.             // method.  This object relates to these object(s) by a
  756.             // foreign key reference.
  757.  
  758.             if ($this->aEtvaServer !== null{
  759.                 if ($this->aEtvaServer->isModified(|| $this->aEtvaServer->isNew()) {
  760.                     $affectedRows += $this->aEtvaServer->save($con);
  761.                 }
  762.                 $this->setEtvaServer($this->aEtvaServer);
  763.             }
  764.  
  765.             if ($this->isNew() ) {
  766.                 $this->modifiedColumns[EtvaAgentPeer::ID;
  767.             }
  768.  
  769.             // If this object has been modified, then save it to the database.
  770.             if ($this->isModified()) {
  771.                 if ($this->isNew()) {
  772.                     $pk EtvaAgentPeer::doInsert($this$con);
  773.                     $affectedRows += 1// we are assuming that there is only 1 row per doInsert() which
  774.                                          // should always be true here (even though technically
  775.                                          // BasePeer::doInsert() can insert multiple rows).
  776.  
  777.                     $this->setId($pk);  //[IMV] update autoincrement primary key
  778.  
  779.                     $this->setNew(false);
  780.                 else {
  781.                     $affectedRows += EtvaAgentPeer::doUpdate($this$con);
  782.                 }
  783.  
  784.                 $this->resetModified()// [HL] After being saved an object is no longer 'modified'
  785.             }
  786.  
  787.             $this->alreadyInSave = false;
  788.  
  789.         }
  790.         return $affectedRows;
  791.     // doSave()
  792.  
  793.     /**
  794.      * Array of ValidationFailed objects.
  795.      * @var        array ValidationFailed[]
  796.      */
  797.     protected $validationFailures = array();
  798.  
  799.     /**
  800.      * Gets any ValidationFailed objects that resulted from last call to validate().
  801.      *
  802.      *
  803.      * @return     array ValidationFailed[]
  804.      * @see        validate()
  805.      */
  806.     public function getValidationFailures()
  807.     {
  808.         return $this->validationFailures;
  809.     }
  810.  
  811.     /**
  812.      * Validates the objects modified field values and all objects related to this table.
  813.      *
  814.      * If $columns is either a column name or an array of column names
  815.      * only those columns are validated.
  816.      *
  817.      * @param      mixed $columns Column name or an array of column names.
  818.      * @return     boolean Whether all columns pass validation.
  819.      * @see        doValidate()
  820.      * @see        getValidationFailures()
  821.      */
  822.     public function validate($columns null)
  823.     {
  824.         $res $this->doValidate($columns);
  825.         if ($res === true{
  826.             $this->validationFailures = array();
  827.             return true;
  828.         else {
  829.             $this->validationFailures = $res;
  830.             return false;
  831.         }
  832.     }
  833.  
  834.     /**
  835.      * This function performs the validation work for complex object models.
  836.      *
  837.      * In addition to checking the current object, all related objects will
  838.      * also be validated.  If all pass then <code>true</code> is returned; otherwise
  839.      * an aggreagated array of ValidationFailed objects will be returned.
  840.      *
  841.      * @param      array $columns Array of column names to validate.
  842.      * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  843.      */
  844.     protected function doValidate($columns null)
  845.     {
  846.         if (!$this->alreadyInValidation{
  847.             $this->alreadyInValidation = true;
  848.             $retval null;
  849.  
  850.             $failureMap array();
  851.  
  852.  
  853.             // We call the validate method on the following object(s) if they
  854.             // were passed to this object by their coresponding set
  855.             // method.  This object relates to these object(s) by a
  856.             // foreign key reference.
  857.  
  858.             if ($this->aEtvaServer !== null{
  859.                 if (!$this->aEtvaServer->validate($columns)) {
  860.                     $failureMap array_merge($failureMap$this->aEtvaServer->getValidationFailures());
  861.                 }
  862.             }
  863.  
  864.  
  865.             if (($retval EtvaAgentPeer::doValidate($this$columns)) !== true{
  866.                 $failureMap array_merge($failureMap$retval);
  867.             }
  868.  
  869.  
  870.  
  871.             $this->alreadyInValidation = false;
  872.         }
  873.  
  874.         return (!empty($failureMap$failureMap true);
  875.     }
  876.  
  877.     /**
  878.      * Retrieves a field from the object by name passed in as a string.
  879.      *
  880.      * @param      string $name name
  881.      * @param      string $type The type of fieldname the $name is of:
  882.      *                      one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  883.      *                      BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  884.      * @return     mixed Value of field.
  885.      */
  886.     public function getByName($name$type BasePeer::TYPE_PHPNAME)
  887.     {
  888.         $pos EtvaAgentPeer::translateFieldName($name$typeBasePeer::TYPE_NUM);
  889.         $field $this->getByPosition($pos);
  890.         return $field;
  891.     }
  892.  
  893.     /**
  894.      * Retrieves a field from the object by Position as specified in the xml schema.
  895.      * Zero-based.
  896.      *
  897.      * @param      int $pos position in xml schema
  898.      * @return     mixed Value of field at $pos
  899.      */
  900.     public function getByPosition($pos)
  901.     {
  902.         switch($pos{
  903.             case 0:
  904.                 return $this->getId();
  905.                 break;
  906.             case 1:
  907.                 return $this->getServerId();
  908.                 break;
  909.             case 2:
  910.                 return $this->getName();
  911.                 break;
  912.             case 3:
  913.                 return $this->getDescription();
  914.                 break;
  915.             case 4:
  916.                 return $this->getService();
  917.                 break;
  918.             case 5:
  919.                 return $this->getIp();
  920.                 break;
  921.             case 6:
  922.                 return $this->getState();
  923.                 break;
  924.             case 7:
  925.                 return $this->getCreatedAt();
  926.                 break;
  927.             case 8:
  928.                 return $this->getUpdatedAt();
  929.                 break;
  930.             default:
  931.                 return null;
  932.                 break;
  933.         // switch()
  934.     }
  935.  
  936.     /**
  937.      * Exports the object as an array.
  938.      *
  939.      * You can specify the key type of the array by passing one of the class
  940.      * type constants.
  941.      *
  942.      * @param      string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  943.      *                         BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. Defaults to BasePeer::TYPE_PHPNAME.
  944.      * @param      boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns.  Defaults to TRUE.
  945.      * @return     an associative array containing the field names (as keys) and field values
  946.      */
  947.     public function toArray($keyType BasePeer::TYPE_PHPNAME$includeLazyLoadColumns true)
  948.     {
  949.         $keys EtvaAgentPeer::getFieldNames($keyType);
  950.         $result array(
  951.             $keys[0=> $this->getId(),
  952.             $keys[1=> $this->getServerId(),
  953.             $keys[2=> $this->getName(),
  954.             $keys[3=> $this->getDescription(),
  955.             $keys[4=> $this->getService(),
  956.             $keys[5=> $this->getIp(),
  957.             $keys[6=> $this->getState(),
  958.             $keys[7=> $this->getCreatedAt(),
  959.             $keys[8=> $this->getUpdatedAt(),
  960.         );
  961.         return $result;
  962.     }
  963.  
  964.     /**
  965.      * Sets a field from the object by name passed in as a string.
  966.      *
  967.      * @param      string $name peer name
  968.      * @param      mixed $value field value
  969.      * @param      string $type The type of fieldname the $name is of:
  970.      *                      one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  971.      *                      BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  972.      * @return     void 
  973.      */
  974.     public function setByName($name$value$type BasePeer::TYPE_PHPNAME)
  975.     {
  976.         $pos EtvaAgentPeer::translateFieldName($name$typeBasePeer::TYPE_NUM);
  977.         return $this->setByPosition($pos$value);
  978.     }
  979.  
  980.     /**
  981.      * Sets a field from the object by Position as specified in the xml schema.
  982.      * Zero-based.
  983.      *
  984.      * @param      int $pos position in xml schema
  985.      * @param      mixed $value field value
  986.      * @return     void 
  987.      */
  988.     public function setByPosition($pos$value)
  989.     {
  990.         switch($pos{
  991.             case 0:
  992.                 $this->setId($value);
  993.                 break;
  994.             case 1:
  995.                 $this->setServerId($value);
  996.                 break;
  997.             case 2:
  998.                 $this->setName($value);
  999.                 break;
  1000.             case 3:
  1001.                 $this->setDescription($value);
  1002.                 break;
  1003.             case 4:
  1004.                 $this->setService($value);
  1005.                 break;
  1006.             case 5:
  1007.                 $this->setIp($value);
  1008.                 break;
  1009.             case 6:
  1010.                 $this->setState($value);
  1011.                 break;
  1012.             case 7:
  1013.                 $this->setCreatedAt($value);
  1014.                 break;
  1015.             case 8:
  1016.                 $this->setUpdatedAt($value);
  1017.                 break;
  1018.         // switch()
  1019.     }
  1020.  
  1021.     /**
  1022.      * Populates the object using an array.
  1023.      *
  1024.      * This is particularly useful when populating an object from one of the
  1025.      * request arrays (e.g. $_POST).  This method goes through the column
  1026.      * names, checking to see whether a matching key exists in populated
  1027.      * array. If so the setByName() method is called for that column.
  1028.      *
  1029.      * You can specify the key type of the array by additionally passing one
  1030.      * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  1031.      * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  1032.      * The default key type is the column's phpname (e.g. 'AuthorId')
  1033.      *
  1034.      * @param      array  $arr     An array to populate the object from.
  1035.      * @param      string $keyType The type of keys the array uses.
  1036.      * @return     void 
  1037.      */
  1038.     public function fromArray($arr$keyType BasePeer::TYPE_PHPNAME)
  1039.     {
  1040.         $keys EtvaAgentPeer::getFieldNames($keyType);
  1041.  
  1042.         if (array_key_exists($keys[0]$arr)) $this->setId($arr[$keys[0]]);
  1043.         if (array_key_exists($keys[1]$arr)) $this->setServerId($arr[$keys[1]]);
  1044.         if (array_key_exists($keys[2]$arr)) $this->setName($arr[$keys[2]]);
  1045.         if (array_key_exists($keys[3]$arr)) $this->setDescription($arr[$keys[3]]);
  1046.         if (array_key_exists($keys[4]$arr)) $this->setService($arr[$keys[4]]);
  1047.         if (array_key_exists($keys[5]$arr)) $this->setIp($arr[$keys[5]]);
  1048.         if (array_key_exists($keys[6]$arr)) $this->setState($arr[$keys[6]]);
  1049.         if (array_key_exists($keys[7]$arr)) $this->setCreatedAt($arr[$keys[7]]);
  1050.         if (array_key_exists($keys[8]$arr)) $this->setUpdatedAt($arr[$keys[8]]);
  1051.     }
  1052.  
  1053.     /**
  1054.      * Build a Criteria object containing the values of all modified columns in this object.
  1055.      *
  1056.      * @return     Criteria The Criteria object containing all modified values.
  1057.      */
  1058.     public function buildCriteria()
  1059.     {
  1060.         $criteria new Criteria(EtvaAgentPeer::DATABASE_NAME);
  1061.  
  1062.         if ($this->isColumnModified(EtvaAgentPeer::ID)) $criteria->add(EtvaAgentPeer::ID$this->id);
  1063.         if ($this->isColumnModified(EtvaAgentPeer::SERVER_ID)) $criteria->add(EtvaAgentPeer::SERVER_ID$this->server_id);
  1064.         if ($this->isColumnModified(EtvaAgentPeer::NAME)) $criteria->add(EtvaAgentPeer::NAME$this->name);
  1065.         if ($this->isColumnModified(EtvaAgentPeer::DESCRIPTION)) $criteria->add(EtvaAgentPeer::DESCRIPTION$this->description);
  1066.         if ($this->isColumnModified(EtvaAgentPeer::SERVICE)) $criteria->add(EtvaAgentPeer::SERVICE$this->service);
  1067.         if ($this->isColumnModified(EtvaAgentPeer::IP)) $criteria->add(EtvaAgentPeer::IP$this->ip);
  1068.         if ($this->isColumnModified(EtvaAgentPeer::STATE)) $criteria->add(EtvaAgentPeer::STATE$this->state);
  1069.         if ($this->isColumnModified(EtvaAgentPeer::CREATED_AT)) $criteria->add(EtvaAgentPeer::CREATED_AT$this->created_at);
  1070.         if ($this->isColumnModified(EtvaAgentPeer::UPDATED_AT)) $criteria->add(EtvaAgentPeer::UPDATED_AT$this->updated_at);
  1071.  
  1072.         return $criteria;
  1073.     }
  1074.  
  1075.     /**
  1076.      * Builds a Criteria object containing the primary key for this object.
  1077.      *
  1078.      * Unlike buildCriteria() this method includes the primary key values regardless
  1079.      * of whether or not they have been modified.
  1080.      *
  1081.      * @return     Criteria The Criteria object containing value(s) for primary key(s).
  1082.      */
  1083.     public function buildPkeyCriteria()
  1084.     {
  1085.         $criteria new Criteria(EtvaAgentPeer::DATABASE_NAME);
  1086.  
  1087.         $criteria->add(EtvaAgentPeer::ID$this->id);
  1088.  
  1089.         return $criteria;
  1090.     }
  1091.  
  1092.     /**
  1093.      * Returns the primary key for this object (row).
  1094.      * @return     int 
  1095.      */
  1096.     public function getPrimaryKey()
  1097.     {
  1098.         return $this->getId();
  1099.     }
  1100.  
  1101.     /**
  1102.      * Generic method to set the primary key (id column).
  1103.      *
  1104.      * @param      int $key Primary key.
  1105.      * @return     void 
  1106.      */
  1107.     public function setPrimaryKey($key)
  1108.     {
  1109.         $this->setId($key);
  1110.     }
  1111.  
  1112.     /**
  1113.      * Sets contents of passed object to values from current object.
  1114.      *
  1115.      * If desired, this method can also make copies of all associated (fkey referrers)
  1116.      * objects.
  1117.      *
  1118.      * @param      object $copyObj An object of EtvaAgent (or compatible) type.
  1119.      * @param      boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  1120.      * @throws     PropelException
  1121.      */
  1122.     public function copyInto($copyObj$deepCopy false)
  1123.     {
  1124.  
  1125.         $copyObj->setServerId($this->server_id);
  1126.  
  1127.         $copyObj->setName($this->name);
  1128.  
  1129.         $copyObj->setDescription($this->description);
  1130.  
  1131.         $copyObj->setService($this->service);
  1132.  
  1133.         $copyObj->setIp($this->ip);
  1134.  
  1135.         $copyObj->setState($this->state);
  1136.  
  1137.         $copyObj->setCreatedAt($this->created_at);
  1138.  
  1139.         $copyObj->setUpdatedAt($this->updated_at);
  1140.  
  1141.  
  1142.         $copyObj->setNew(true);
  1143.  
  1144.         $copyObj->setId(NULL)// this is a auto-increment column, so set to default value
  1145.  
  1146.     }
  1147.  
  1148.     /**
  1149.      * Makes a copy of this object that will be inserted as a new row in table when saved.
  1150.      * It creates a new object filling in the simple attributes, but skipping any primary
  1151.      * keys that are defined for the table.
  1152.      *
  1153.      * If desired, this method can also make copies of all associated (fkey referrers)
  1154.      * objects.
  1155.      *
  1156.      * @param      boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  1157.      * @return     EtvaAgent Clone of current object.
  1158.      * @throws     PropelException
  1159.      */
  1160.     public function copy($deepCopy false)
  1161.     {
  1162.         // we use get_class(), because this might be a subclass
  1163.         $clazz get_class($this);
  1164.         $copyObj new $clazz();
  1165.         $this->copyInto($copyObj$deepCopy);
  1166.         return $copyObj;
  1167.     }
  1168.  
  1169.     /**
  1170.      * Returns a peer instance associated with this om.
  1171.      *
  1172.      * Since Peer classes are not to have any instance attributes, this method returns the
  1173.      * same instance for all member of this class. The method could therefore
  1174.      * be static, but this would prevent one from overriding the behavior.
  1175.      *
  1176.      * @return     EtvaAgentPeer 
  1177.      */
  1178.     public function getPeer()
  1179.     {
  1180.         if (self::$peer === null{
  1181.             self::$peer new EtvaAgentPeer();
  1182.         }
  1183.         return self::$peer;
  1184.     }
  1185.  
  1186.     /**
  1187.      * Declares an association between this object and a EtvaServer object.
  1188.      *
  1189.      * @param      EtvaServer $v 
  1190.      * @return     EtvaAgent The current object (for fluent API support)
  1191.      * @throws     PropelException
  1192.      */
  1193.     public function setEtvaServer(EtvaServer $v null)
  1194.     {
  1195.         if ($v === null{
  1196.             $this->setServerId(NULL);
  1197.         else {
  1198.             $this->setServerId($v->getId());
  1199.         }
  1200.  
  1201.         $this->aEtvaServer = $v;
  1202.  
  1203.         // Add binding for other direction of this n:n relationship.
  1204.         // If this object has already been added to the EtvaServer object, it will not be re-added.
  1205.         if ($v !== null{
  1206.             $v->addEtvaAgent($this);
  1207.         }
  1208.  
  1209.         return $this;
  1210.     }
  1211.  
  1212.  
  1213.     /**
  1214.      * Get the associated EtvaServer object
  1215.      *
  1216.      * @param      PropelPDO Optional Connection object.
  1217.      * @return     EtvaServer The associated EtvaServer object.
  1218.      * @throws     PropelException
  1219.      */
  1220.     public function getEtvaServer(PropelPDO $con null)
  1221.     {
  1222.         if ($this->aEtvaServer === null && ($this->server_id !== null)) {
  1223.             $c new Criteria(EtvaServerPeer::DATABASE_NAME);
  1224.             $c->add(EtvaServerPeer::ID$this->server_id);
  1225.             $this->aEtvaServer = EtvaServerPeer::doSelectOne($c$con);
  1226.             /* The following can be used additionally to
  1227.                guarantee the related object contains a reference
  1228.                to this object.  This level of coupling may, however, be
  1229.                undesirable since it could result in an only partially populated collection
  1230.                in the referenced object.
  1231.                $this->aEtvaServer->addEtvaAgents($this);
  1232.              */
  1233.         }
  1234.         return $this->aEtvaServer;
  1235.     }
  1236.  
  1237.     /**
  1238.      * Resets all collections of referencing foreign keys.
  1239.      *
  1240.      * This method is a user-space workaround for PHP's inability to garbage collect objects
  1241.      * with circular references.  This is currently necessary when using Propel in certain
  1242.      * daemon or large-volumne/high-memory operations.
  1243.      *
  1244.      * @param      boolean $deep Whether to also clear the references on all associated objects.
  1245.      */
  1246.     public function clearAllReferences($deep false)
  1247.     {
  1248.         if ($deep{
  1249.         // if ($deep)
  1250.  
  1251.             $this->aEtvaServer = null;
  1252.     }
  1253.  
  1254.  
  1255.   public function __call($method$arguments)
  1256.   {
  1257.     if (!$callable sfMixer::getCallable('BaseEtvaAgent:'.$method))
  1258.     {
  1259.       throw new sfException(sprintf('Call to undefined method BaseEtvaAgent::%s'$method));
  1260.     }
  1261.  
  1262.     array_unshift($arguments$this);
  1263.  
  1264.     return call_user_func_array($callable$arguments);
  1265.   }
  1266.  
  1267.  
  1268. // BaseEtvaAgent

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