Overview

Namespaces

  • cli_db
    • propel
      • map
      • om
  • cli_import
  • LoggedPDO
  • None
  • PHP
  • webservices
    • cart
    • combisearch
    • details
      • annotations
        • feature
    • graphs
      • barplot
      • genome
    • listing
    • queue

Classes

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