當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。