Gets previous sibling for the given node if it exists

@param      ConnectionInterface $con Connection to use.
@return     ChildCategory|null         Propel object if exists else null
178830
public function getPrevSibling(ConnectionInterface $con = null)
    {
        return ChildCategoryQuery::create()
            ->filterByTreeRight($this->getLeftValue() - 1)
            ->findOne($con);
    }
1371702
public function hasPrevSibling(ConnectionInterface $con = null)
    {
        if (!ChildCategoryQuery::isValid($this)) {
            return false;
        }

        return ChildCategoryQuery::create()
            ->filterByTreeRight($this->getLeftValue() - 1)
            ->exists($con);
    }
752253
protected function doInsert(ConnectionInterface $con)
    {
        $modifiedColumns = array();
        $index = 0;

        $this->modifiedColumns[StructureNodeTableMap::COL_ID] = true;
        if (null !== $this->id) {
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . StructureNodeTableMap::COL_ID . ')');
        }

         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(StructureNodeTableMap::COL_ID)) {
            $modifiedColumns[':p' . $index++]  = '`id`';
        }
        if ($this->isColumnModified(StructureNodeTableMap::COL_TYPE)) {
            $modifiedColumns[':p' . $index++]  = '`type`';
        }
        if ($this->isColumnModified(StructureNodeTableMap::COL_SKILL_ID)) {
            $modifiedColumns[':p' . $index++]  = '`skill_id`';
        }
        if ($this->isColumnModified(StructureNodeTableMap::COL_TITLE)) {
            $modifiedColumns[':p' . $index++]  = '`title`';
        }
        if ($this->isColumnModified(StructureNodeTableMap::COL_DESCENDANT_CLASS)) {
            $modifiedColumns[':p' . $index++]  = '`descendant_class`';
        }

        $sql = sprintf(
            'INSERT INTO `kk_trixionary_structure_node` (%s) VALUES (%s)',
            implode(', ', $modifiedColumns),
            implode(', ', array_keys($modifiedColumns))
        );

        try {
            $stmt = $con->prepare($sql);
            foreach ($modifiedColumns as $identifier => $columnName) {
                switch ($columnName) {
                    case '`id`':
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                        break;
                    case '`type`':
                        $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR);
                        break;
                    case '`skill_id`':
                        $stmt->bindValue($identifier, $this->skill_id, PDO::PARAM_INT);
                        break;
                    case '`title`':
                        $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
                        break;
                    case '`descendant_class`':
                        $stmt->bindValue($identifier, $this->descendant_class, PDO::PARAM_STR);
                        break;
                }
            }
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
        }

        try {
            $pk = $con->lastInsertId();
        } catch (Exception $e) {
            throw new PropelException('Unable to get autoincrement id.', 0, $e);
        }
        $this->setId($pk);

        $this->setNew(false);
    }
294721
static public function fixLevels(ConnectionInterface $con = null)
    {
        $c = new Criteria();
        $c->addAscendingOrderByColumn(ChildCategory::LEFT_COL);
        $dataFetcher = ChildCategoryQuery::create(null, $c)->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);

        // set the class once to avoid overhead in the loop
        $cls = CategoryTableMap::getOMClass(false);
        $level = null;
        // iterate over the statement
        while ($row = $dataFetcher->fetch()) {

            // hydrate object
            $key = CategoryTableMap::getPrimaryKeyHashFromRow($row, 0);
            /** @var $obj ChildCategory */
            if (null === ($obj = CategoryTableMap::getInstanceFromPool($key))) {
                $obj = new $cls();
                $obj->hydrate($row);
                CategoryTableMap::addInstanceToPool($obj, $key);
            }

            // compute level
            // Algorithm shamelessly stolen from sfPropelActAsNestedSetBehaviorPlugin
            // Probably authored by Tristan Rivoallan
            if ($level === null) {
                $level = 0;
                $i = 0;
                $prev = array($obj->getRightValue());
            } else {
                while ($obj->getRightValue() > $prev[$i]) {
                    $i--;
                }
                $level = ++$i;
                $prev[$i] = $obj->getRightValue();
            }

            // update level in node if necessary
            if ($obj->getLevel() !== $level) {
                $obj->setLevel($level);
                $obj->save($con);
            }
        }
        $dataFetcher->close();
    }
155920
public function getFirstChild(Criteria $criteria = null, ConnectionInterface $con = null)
    {
        if ($this->isLeaf()) {
            return null;
        } else {
            return ChildCategoryQuery::create(null, $criteria)
                ->childrenOf($this)
                ->orderByBranch()
                ->findOne($con);
        }
    }
546037
protected function doInsert(ConnectionInterface $con)
    {
        $modifiedColumns = array();
        $index = 0;

        $this->modifiedColumns[LineageTableMap::COL_ID] = true;
        if (null !== $this->id) {
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . LineageTableMap::COL_ID . ')');
        }

         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(LineageTableMap::COL_ID)) {
            $modifiedColumns[':p' . $index++]  = '`id`';
        }
        if ($this->isColumnModified(LineageTableMap::COL_SKILL_ID)) {
            $modifiedColumns[':p' . $index++]  = '`skill_id`';
        }
        if ($this->isColumnModified(LineageTableMap::COL_ANCESTOR_ID)) {
            $modifiedColumns[':p' . $index++]  = '`ancestor_id`';
        }
        if ($this->isColumnModified(LineageTableMap::COL_POSITION)) {
            $modifiedColumns[':p' . $index++]  = '`position`';
        }

        $sql = sprintf(
            'INSERT INTO `kk_trixionary_lineage` (%s) VALUES (%s)',
            implode(', ', $modifiedColumns),
            implode(', ', array_keys($modifiedColumns))
        );

        try {
            $stmt = $con->prepare($sql);
            foreach ($modifiedColumns as $identifier => $columnName) {
                switch ($columnName) {
                    case '`id`':
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                        break;
                    case '`skill_id`':
                        $stmt->bindValue($identifier, $this->skill_id, PDO::PARAM_INT);
                        break;
                    case '`ancestor_id`':
                        $stmt->bindValue($identifier, $this->ancestor_id, PDO::PARAM_INT);
                        break;
                    case '`position`':
                        $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
                        break;
                }
            }
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
        }

        try {
            $pk = $con->lastInsertId();
        } catch (Exception $e) {
            throw new PropelException('Unable to get autoincrement id.', 0, $e);
        }
        $this->setId($pk);

        $this->setNew(false);
    }
1271541
public function getEndPosition(ConnectionInterface $con = null)
    {
        if ($this->aEndPosition === null && ($this->end_position_id !== null)) {
            $this->aEndPosition = ChildPositionQuery::create()->findPk($this->end_position_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->aEndPosition->addSkillsRelatedByEndPositionId($this);
             */
        }

        return $this->aEndPosition;
    }
1205087
public function getAttributeType(ConnectionInterface $con = null)
    {
        if ($this->aAttributeType === null && ($this->attribute_type_id !== null)) {
            $this->aAttributeType = ChildAttributeTypeQuery::create()->findPk($this->attribute_type_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->aAttributeType->addAttributeAttributeTypes($this);
             */
        }

        return $this->aAttributeType;
    }
1319188
public function getKstrukturRoot(ConnectionInterface $con = null)
    {
        if ($this->aKstrukturRoot === null && ($this->kstruktur_id !== null)) {
            $this->aKstrukturRoot = ChildKstrukturQuery::create()->findPk($this->kstruktur_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->aKstrukturRoot->addRootSkills($this);
             */
        }

        return $this->aKstrukturRoot;
    }
32440
public function getDealerAdmin(ConnectionInterface $con = null)
    {
        if ($this->aDealerAdmin === null && ($this->id !== null)) {
            $this->aDealerAdmin = ChildDealerAdminQuery::create()->findPk($this->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->aDealerAdmin->addDealerAdminVersions($this);
             */
        }

        return $this->aDealerAdmin;
    }
141897
public function getFunctionPhaseRoot(ConnectionInterface $con = null)
    {
        if ($this->aFunctionPhaseRoot === null && ($this->function_phase_id !== null)) {
            $this->aFunctionPhaseRoot = ChildFunctionPhaseQuery::create()->findPk($this->function_phase_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->aFunctionPhaseRoot->addRootSkills($this);
             */
        }

        return $this->aFunctionPhaseRoot;
    }
1055165
public function findRoot(ConnectionInterface $con = null)
    {
        return $this
            ->addUsingAlias(ChildCategory::LEFT_COL, 1, Criteria::EQUAL)
            ->findOne($con);
    }
86233
public function getSkillRelatedByParentId(ConnectionInterface $con = null)
    {
        if ($this->aSkillRelatedByParentId === null && ($this->parent_id !== null)) {
            $this->aSkillRelatedByParentId = ChildSkillQuery::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->aSkillRelatedByParentId->addParents($this);
             */
        }

        return $this->aSkillRelatedByParentId;
    }
261387
public function getSyncParent($con = null)
    {
        $parent = $this->getParentOrCreate($con);
        $parent->setType($this->getType());
        $parent->setSkillId($this->getSkillId());
        $parent->setTitle($this->getTitle());
        if ($this->getSkill() && $this->getSkill()->isNew()) {
            $parent->setSkill($this->getSkill());
        }

        return $parent;
    }
1282173
public function getDealerContent(ConnectionInterface $con = null)
    {
        if ($this->aDealerContent === null && ($this->id !== null)) {
            $this->aDealerContent = ChildDealerContentQuery::create()->findPk($this->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->aDealerContent->addDealerContentVersions($this);
             */
        }

        return $this->aDealerContent;
    }
496763
public function getStartPosition(ConnectionInterface $con = null)
    {
        if ($this->aStartPosition === null && ($this->start_position_id !== null)) {
            $this->aStartPosition = ChildPositionQuery::create()->findPk($this->start_position_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->aStartPosition->addSkillsRelatedByStartPositionId($this);
             */
        }

        return $this->aStartPosition;
    }
900099
public function getDescendants(Criteria $criteria = null, ConnectionInterface $con = null)
    {
        if ($this->isLeaf()) {
            return array();
        } else {
            return ChildCategoryQuery::create(null, $criteria)
                ->descendantsOf($this)
                ->orderByBranch()
                ->find($con);
        }
    }