/**
  * Performs an INSERT on the database, given a StructureNode or Criteria object.
  *
  * @param mixed               $criteria Criteria or StructureNode object containing data that is used to create the INSERT statement.
  * @param ConnectionInterface $con the ConnectionInterface connection to use
  * @return mixed           The new primary key.
  * @throws PropelException Any exceptions caught during processing will be
  *                         rethrown wrapped into a PropelException.
  */
 public static function doInsert($criteria, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(StructureNodeTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from StructureNode object
     }
     if ($criteria->containsKey(StructureNodeTableMap::COL_ID) && $criteria->keyContainsValue(StructureNodeTableMap::COL_ID)) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . StructureNodeTableMap::COL_ID . ')');
     }
     // Set the correct dbName
     $query = StructureNodeQuery::create()->mergeWith($criteria);
     // use transaction because $criteria could contain info
     // for more than one table (I guess, conceivably)
     return $con->transaction(function () use($con, $query) {
         return $query->doInsert($con);
     });
 }
Example #2
0
 /**
  * Deletes all rows from the kk_trixionary_function_phase table.
  *
  * @param ConnectionInterface $con the connection to use
  * @return int The number of affected rows (if supported by underlying database driver).
  */
 public function doDeleteAll(ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(FunctionPhaseTableMap::DATABASE_NAME);
     }
     // use transaction because $criteria could contain info
     // for more than one table or we could emulating ON DELETE CASCADE, etc.
     return $con->transaction(function () use($con) {
         $affectedRows = 0;
         // initialize var to track total num of affected rows
         $affectedRows += parent::doDeleteAll($con);
         // Because this db requires some delete cascade/set null emulation, we have to
         // clear the cached instance *after* the emulation has happened (since
         // instances get re-added by the select statement contained therein).
         FunctionPhaseTableMap::clearInstancePool();
         FunctionPhaseTableMap::clearRelatedInstancePool();
         return $affectedRows;
     });
 }
Example #3
0
 /**
  * Get or Create the parent ChildStructureNode object of the current object
  *
  * @return    ChildStructureNode The parent object
  */
 public function getParentOrCreate($con = null)
 {
     if ($this->isNew()) {
         if ($this->isPrimaryKeyNull()) {
             $parent = new ChildStructureNode();
             $parent->setDescendantClass('gossi\\trixionary\\model\\Kstruktur');
             return $parent;
         } else {
             $parent = \gossi\trixionary\model\StructureNodeQuery::create()->findPk($this->getPrimaryKey(), $con);
             if (null === $parent || null !== $parent->getDescendantClass()) {
                 $parent = new ChildStructureNode();
                 $parent->setPrimaryKey($this->getPrimaryKey());
                 $parent->setDescendantClass('gossi\\trixionary\\model\\Kstruktur');
             }
             return $parent;
         }
     } else {
         return ChildStructureNodeQuery::create()->findPk($this->getPrimaryKey(), $con);
     }
 }
Example #4
0
 /**
  * Returns a new ChildStructureNodeQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return ChildStructureNodeQuery
  */
 public static function create($modelAlias = null, Criteria $criteria = null)
 {
     if ($criteria instanceof ChildStructureNodeQuery) {
         return $criteria;
     }
     $query = new ChildStructureNodeQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
Example #5
0
 /**
  * Gets the number of StructureNode objects related by a many-to-many relationship
  * to the current object by way of the kk_trixionary_structure_node_parent cross-reference table.
  *
  * @param      Criteria $criteria Optional query object to filter the query
  * @param      boolean $distinct Set to true to force count distinct
  * @param      ConnectionInterface $con Optional connection object
  *
  * @return int the number of related StructureNode objects
  */
 public function countStructureNodesRelatedByStructureNodeId(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
 {
     $partial = $this->collStructureNodesRelatedByStructureNodeIdPartial && !$this->isNew();
     if (null === $this->collStructureNodesRelatedByStructureNodeId || null !== $criteria || $partial) {
         if ($this->isNew() && null === $this->collStructureNodesRelatedByStructureNodeId) {
             return 0;
         } else {
             if ($partial && !$criteria) {
                 return count($this->getStructureNodesRelatedByStructureNodeId());
             }
             $query = ChildStructureNodeQuery::create(null, $criteria);
             if ($distinct) {
                 $query->distinct();
             }
             return $query->filterByStructureNodeRelatedByParentId($this)->count($con);
         }
     } else {
         return count($this->collStructureNodesRelatedByStructureNodeId);
     }
 }
Example #6
0
 /**
  * Get the associated ChildStructureNode object
  *
  * @param  ConnectionInterface $con Optional Connection object.
  * @return ChildStructureNode The associated ChildStructureNode object.
  * @throws PropelException
  */
 public function getStructureNodeRelatedByParentId(ConnectionInterface $con = null)
 {
     if ($this->aStructureNodeRelatedByParentId === null && $this->parent_id !== null) {
         $this->aStructureNodeRelatedByParentId = ChildStructureNodeQuery::create()->findPk($this->parent_id, $con);
         /* The following can be used additionally to
               guarantee the related object contains a reference
               to this object.  This level of coupling may, however, be
               undesirable since it could result in an only partially populated collection
               in the referenced object.
               $this->aStructureNodeRelatedByParentId->addStructureNodeParentsRelatedByParentId($this);
            */
     }
     return $this->aStructureNodeRelatedByParentId;
 }