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