本文整理汇总了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;
}
示例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;
}