コード例 #1
0
ファイル: Add.php プロジェクト: halfer/Meshing
 /**
  * Writes the connection record
  * 
  * @todo Need to validate string lengths etc (or catch exceptions properly)
  */
 protected function writeRecord()
 {
     $connection = new P2PConnection();
     $connection->setName($this->opts->name);
     $connection->setAdaptor($this->opts->adaptor);
     $connection->setHost($this->opts->host);
     if ($this->opts->database) {
         $connection->setDatabase($this->opts->database);
     }
     if ($this->opts->user) {
         $connection->setUsername($this->opts->user);
     }
     if ($this->opts->password) {
         $connection->setPassword($this->opts->password);
     }
     $connection->save();
 }
コード例 #2
0
ファイル: BaseP2POwnNode.php プロジェクト: halfer/Meshing
 /**
  * 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->aP2PConnection !== null) {
             if ($this->aP2PConnection->isModified() || $this->aP2PConnection->isNew()) {
                 $affectedRows += $this->aP2PConnection->save($con);
             }
             $this->setP2PConnection($this->aP2PConnection);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = P2POwnNodePeer::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(P2POwnNodePeer::ID)) {
                     throw new PropelException('Cannot insert a value for auto-increment primary key (' . P2POwnNodePeer::ID . ')');
                 }
                 $pk = BasePeer::doInsert($criteria, $con);
                 $affectedRows += 1;
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += P2POwnNodePeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         if ($this->collMeshingTrustLocalsRelatedByFromOwnNodeId !== null) {
             foreach ($this->collMeshingTrustLocalsRelatedByFromOwnNodeId as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collMeshingTrustLocalsRelatedByToOwnNodeId !== null) {
             foreach ($this->collMeshingTrustLocalsRelatedByToOwnNodeId as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collMeshingTrustRemotesRelatedByFromOwnNodeId !== null) {
             foreach ($this->collMeshingTrustRemotesRelatedByFromOwnNodeId as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collMeshingTrustRemotesRelatedByInOwnNodeId !== null) {
             foreach ($this->collMeshingTrustRemotesRelatedByInOwnNodeId as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }