コード例 #1
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aMeshingSchema !== null) {
             if ($this->aMeshingSchema->isModified() || $this->aMeshingSchema->isNew()) {
                 $affectedRows += $this->aMeshingSchema->save($con);
             }
             $this->setMeshingSchema($this->aMeshingSchema);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = MeshingSchemaTablePeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $criteria = $this->buildCriteria();
                 if ($criteria->keyContainsValue(MeshingSchemaTablePeer::ID)) {
                     throw new PropelException('Cannot insert a value for auto-increment primary key (' . MeshingSchemaTablePeer::ID . ')');
                 }
                 $pk = BasePeer::doInsert($criteria, $con);
                 $affectedRows += 1;
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += MeshingSchemaTablePeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
コード例 #2
0
ファイル: Add.php プロジェクト: halfer/Meshing
 protected function writeRecords($tableNames)
 {
     $schema = new MeshingSchema();
     $schema->setName($this->opts->name);
     $schema->setInstalledAt(time());
     $schema->save();
     foreach ($tableNames as $tableName) {
         $schemaTable = new MeshingSchemaTable();
         $schemaTable->setMeshingSchema($schema);
         $schemaTable->setName($tableName);
         $schemaTable->save();
     }
 }
コード例 #3
0
ファイル: DatabaseTestCase.php プロジェクト: halfer/Meshing
 /**
  * Creates a new KnownNode for node models
  * 
  * @param PropelPDO $con PDO connection object
  * @return TestModelKnownNode 
  */
 protected function createKnownNode(BaseObject $node, PropelPDO $con = null)
 {
     $this->initConnections();
     // Look up schema, and create an empty one if required
     $schema = MeshingSchemaQuery::create()->findOneByName($this->package, $this->conSystem);
     if (!$schema) {
         $schema = new MeshingSchema();
         $schema->setName($this->package);
         $schema->setInstalledAt(time());
         $schema->save($this->conSystem);
     }
     /* @var $node TestModelKnownNode */
     $node->setName('Us!');
     $node->setFqdn('http://example.com/path');
     $node->setSchemaId($schema->getId());
     $node->save($con);
     return $node;
 }