# File core/lib/Thelia/Model/om/BaseGroupResource.php | thelia

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