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