当前位置: 首页>>代码示例>>PHP>>正文


PHP Doctrine_Query::set方法代码示例

本文整理汇总了PHP中Doctrine_Query::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Query::set方法的具体用法?PHP Doctrine_Query::set怎么用?PHP Doctrine_Query::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine_Query的用法示例。


在下文中一共展示了Doctrine_Query::set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: insertAsParentOf

 /**
  * inserts node as parent of dest record
  *
  * @return bool
  * @todo Wrap in transaction          
  */
 public function insertAsParentOf(Doctrine_Record $dest)
 {
     // cannot insert a node that has already has a place within the tree
     if ($this->isValidNode()) {
         return false;
     }
     // cannot insert as parent of root
     if ($dest->getNode()->isRoot()) {
         return false;
     }
     // cannot insert as parent of itself
     if ($dest === $this->record || $dest->exists() && $this->record->exists() && $dest->identifier() === $this->record->identifier()) {
         throw new Doctrine_Tree_Exception("Cannot insert node as parent of itself");
         return false;
     }
     $newLeft = $dest->getNode()->getLeftValue();
     $newRight = $dest->getNode()->getRightValue() + 2;
     $newRoot = $dest->getNode()->getRootValue();
     $newLevel = $dest->getNode()->getLevel();
     $conn = $this->record->getTable()->getConnection();
     try {
         $conn->beginInternalTransaction();
         // Make space for new node
         $this->shiftRLValues($dest->getNode()->getRightValue() + 1, 2, $newRoot);
         // Slide child nodes over one and down one to allow new parent to wrap them
         $componentName = $this->_tree->getBaseComponent();
         $q = new Doctrine_Query();
         $q->update($componentName);
         $q->set("{$componentName}.lft", "{$componentName}.lft + 1");
         $q->set("{$componentName}.rgt", "{$componentName}.rgt + 1");
         $q->set("{$componentName}.level", "{$componentName}.level + 1");
         $q->where("{$componentName}.lft >= ? AND {$componentName}.rgt <= ?", array($newLeft, $newRight));
         $q = $this->_tree->returnQueryWithRootId($q, $newRoot);
         $q->execute();
         $this->record['level'] = $newLevel;
         $this->insertNode($newLeft, $newRight, $newRoot);
         $conn->commit();
     } catch (Exception $e) {
         $conn->rollback();
         throw $e;
     }
     return true;
 }
开发者ID:hasanozgan,项目名称:kissabe,代码行数:49,代码来源:NestedSet.php

示例2: insertAsParentOf

 /**
  * inserts node as parent of dest record
  *
  * @return bool
  * @todo Wrap in transaction          
  */
 public function insertAsParentOf(Doctrine_Record $dest)
 {
     // cannot insert a node that has already has a place within the tree
     if ($this->isValidNode()) {
         return false;
     }
     // cannot insert as parent of root
     if ($dest->getNode()->isRoot()) {
         return false;
     }
     $newLeft = $dest->getNode()->getLeftValue();
     $newRight = $dest->getNode()->getRightValue() + 2;
     $newRoot = $dest->getNode()->getRootValue();
     $newLevel = $dest->getNode()->getLevel();
     // Make space for new node
     $this->shiftRLValues($dest->getNode()->getRightValue() + 1, 2, $newRoot);
     // Slide child nodes over one and down one to allow new parent to wrap them
     $componentName = $this->_tree->getBaseComponent();
     $q = new Doctrine_Query();
     $q->update($componentName);
     $q->set("{$componentName}.lft", "{$componentName}.lft + 1");
     $q->set("{$componentName}.rgt", "{$componentName}.rgt + 1");
     $q->set("{$componentName}.level", "{$componentName}.level + 1");
     $q->where("{$componentName}.lft >= ? AND {$componentName}.rgt <= ?", array($newLeft, $newRight));
     $q = $this->_tree->returnQueryWithRootId($q, $newRoot);
     $q->execute();
     $this->record['level'] = $newLevel;
     $this->insertNode($newLeft, $newRight, $newRoot);
     return true;
 }
开发者ID:amitesh-singh,项目名称:Enlightenment,代码行数:36,代码来源:NestedSet.php


注:本文中的Doctrine_Query::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。