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


PHP Doctrine_Query::update方法代码示例

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


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

示例1: testUpdateSupportsColumnReferencing

    public function testUpdateSupportsColumnReferencing()
    {
        $q = new Doctrine_Query();

        $q->update('User u')->set('u.id', 'u.id + 1');

        $this->assertEqual($q->getQuery(), "UPDATE entity SET id = id + 1 WHERE (type = 0)");
    }
开发者ID:prismhdd,项目名称:victorioussecret,代码行数:8,代码来源:UpdateTestCase.php

示例2: testTicket

 public function testTicket()
 {
     $q = new Doctrine_Query();
     try {
         // simple query with deep relations
         $q->update('Email')->set('address', '?', 'new@doctrine.org')->where('address = ?', 'david.stendardi@adenclassifieds.com')->execute();
     } catch (Exception $e) {
         $this->fail('Query :: set do not support values containing dot. Exception: ' . $e->getMessage());
     }
 }
开发者ID:swk,项目名称:bluebox,代码行数:10,代码来源:927TestCase.php

示例3: testTicket

 public function testTicket()
 {
     try {
         $q = new Doctrine_Query();
         $q->update('EnumUpdateBug')->set('bla_id', '?', 5)->set('separator', '?', 'pipe')->where('id = 1')->execute();
     } catch (Exception $e) {
         $this->fail($e->getMessage());
     }
     $q = new Doctrine_Query();
     $row = $q->select('a.*')->from('EnumUpdateBug a')->where('a.id = 1')->fetchOne();
     $this->assertEqual($row->bla_id, 5);
 }
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:12,代码来源:935TestCase.php

示例4: testDqlUpdate

 public function testDqlUpdate()
 {
     $query = new Doctrine_Query($this->connection);
     $query->update('EnumTest2 u')->set('u.status', '?', 'verified');
     $this->assertEqual($query->getSqlQuery(), 'UPDATE enum_test2 SET status = ?');
     $query->execute();
     try {
         $query = new Doctrine_Query($this->connection);
         $ret = $query->query("FROM EnumTest2 WHERE EnumTest2.status = 'verified'");
         $this->assertEqual(count($ret), 1);
     } catch (Exception $e) {
         $this->fail();
     }
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:14,代码来源:EnumTestCase.php

示例5: linkInDb

 public function linkInDb($alias, $ids)
 {
     $identifier = array_values($this->identifier());
     $identifier = array_shift($identifier);
     $rel = $this->getTable()->getRelation($alias);
     if ($rel instanceof Doctrine_Relation_Association) {
         $modelClassName = $rel->getAssociationTable()->getComponentName();
         $localFieldName = $rel->getLocalFieldName();
         $localFieldDef = $rel->getAssociationTable()->getColumnDefinition($localFieldName);
         if ($localFieldDef['type'] == 'integer') {
             $identifier = (int) $identifier;
         }
         $foreignFieldName = $rel->getForeignFieldName();
         $foreignFieldDef = $rel->getAssociationTable()->getColumnDefinition($foreignFieldName);
         if ($foreignFieldDef['type'] == 'integer') {
             for ($i = 0, $l = count($ids); $i < $l; $i++) {
                 $ids[$i] = (int) $ids[$i];
             }
         }
         foreach ($ids as $id) {
             $record = new $modelClassName();
             $record[$localFieldName] = $identifier;
             $record[$foreignFieldName] = $id;
             $record->save();
         }
     } else {
         if ($rel instanceof Doctrine_Relation_ForeignKey) {
             $q = new Doctrine_Query();
             $q->update($rel->getTable()->getComponentName())->set($rel->getForeign(), '?', array_values($this->identifier()));
             if (count($ids) > 0) {
                 $q->whereIn($rel->getTable()->getIdentifier(), $ids);
             }
             $q->execute();
         } else {
             if ($rel instanceof Doctrine_Relation_LocalKey) {
                 $q = new Doctrine_Query();
                 $q->update($this->getTable()->getComponentName())->set($rel->getLocalFieldName(), '?', $ids);
                 if (count($ids) > 0) {
                     $q->whereIn($rel->getTable()->getIdentifier(), array_values($this->identifier()));
                 }
                 $q->execute();
             }
         }
     }
     return $this;
 }
开发者ID:hasanozgan,项目名称:kissabe,代码行数:46,代码来源:Record.php

示例6: testUpdateSupportsComplexExpressions

 public function testUpdateSupportsComplexExpressions()
 {
     $q = new Doctrine_Query();
     $q->update('User u')->set('u.name', "CONCAT(?, CONCAT(':', SUBSTRING(u.name, LOCATE(':', u.name)+1, LENGTH(u.name) - LOCATE(':', u.name)+1)))", array('gblanco'))->where('u.id IN (SELECT u2.id FROM User u2 WHERE u2.name = ?) AND u.email_id = ?', array('guilhermeblanco', 5));
     $this->assertEqual($q->getSqlQuery(), "UPDATE entity SET name = CONCAT(?, CONCAT(':', SUBSTRING(name, LOCATE(':', name)+1, LENGTH(name) - LOCATE(':', name)+1))) WHERE (id IN (SELECT e2.id AS e2__id FROM entity e2 WHERE (e2.name = ? AND (e2.type = 0))) AND email_id = ?) AND (type = 0)");
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:6,代码来源:UpdateTestCase.php

示例7: shiftRlValues

 /**
  * adds '$delta' to all Left and Right values that are >= '$first'. '$delta' can also be negative.
  *
  * Note: This method does wrap its database queries in a transaction. This should be done
  * by the invoking code.
  *
  * @param int $first         First node to be shifted
  * @param int $delta         Value to be shifted by, can be negative
  */
 private function shiftRlValues($first, $delta, $rootId = 1)
 {
     $qLeft = new Doctrine_Query();
     $qRight = new Doctrine_Query();
     // shift left columns
     $componentName = $this->_tree->getBaseComponent();
     $qLeft = $qLeft->update($componentName)->set($componentName . '.lft', $componentName . '.lft + ?', $delta)->where($componentName . '.lft >= ?', $first);
     $qLeft = $this->_tree->returnQueryWithRootId($qLeft, $rootId);
     $resultLeft = $qLeft->execute();
     // shift right columns
     $resultRight = $qRight->update($componentName)->set($componentName . '.rgt', $componentName . '.rgt + ?', $delta)->where($componentName . '.rgt >= ?', $first);
     $qRight = $this->_tree->returnQueryWithRootId($qRight, $rootId);
     $resultRight = $qRight->execute();
 }
开发者ID:hasanozgan,项目名称:kissabe,代码行数:23,代码来源:NestedSet.php

示例8: 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:yasirgit,项目名称:afids,代码行数:49,代码来源:NestedSet.php

示例9: testUpdateQuerySupportsIdentifierQuoting8

 public function testUpdateQuerySupportsIdentifierQuoting8()
 {
     $q = new Doctrine_Query();
     $q->update('User u')->set('u.id', 'u.id + 1')->where('u.name = ?');
     $this->assertEqual($q->getSqlQuery(), 'UPDATE "entity" SET "id" = "id" + 1 WHERE ("name" = ? AND ("type" = 0))');
     $this->conn->setAttribute(Doctrine_Core::ATTR_QUOTE_IDENTIFIER, false);
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:7,代码来源:IdentifierQuotingTestCase.php

示例10: shiftRlValues

 /**
  * adds '$delta' to all Left and Right values that are >= '$first'. '$delta' can also be negative.
  *
  * @param int $first         First node to be shifted
  * @param int $delta         Value to be shifted by, can be negative
  */
 private function shiftRlValues($first, $delta, $rootId = 1)
 {
     $qLeft = new Doctrine_Query();
     $qRight = new Doctrine_Query();
     // TODO: Wrap in transaction
     // shift left columns
     $componentName = $this->record->getTable()->getComponentName();
     $qLeft = $qLeft->update($componentName)->set($componentName . '.lft', 'lft + ' . $delta)->where($componentName . '.lft >= ?', $first);
     $qLeft = $this->record->getTable()->getTree()->returnQueryWithRootId($qLeft, $rootId);
     $resultLeft = $qLeft->execute();
     // shift right columns
     $resultRight = $qRight->update($componentName)->set($componentName . '.rgt', 'rgt + ' . $delta)->where($componentName . '.rgt >= ?', $first);
     $qRight = $this->record->getTable()->getTree()->returnQueryWithRootId($qRight, $rootId);
     $resultRight = $qRight->execute();
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:21,代码来源:NestedSet.php

示例11: unlink

 /**
  * unlink
  * removes links from this record to given records
  * if no ids are given, it removes all links
  *
  * @param string $alias     related component alias
  * @param array $ids        the identifiers of the related records
  * @return Doctrine_Record  this object
  */
 public function unlink($alias, $ids = array())
 {
     $ids = (array) $ids;
     $q = new Doctrine_Query();
     $rel = $this->getTable()->getRelation($alias);
     if ($rel instanceof Doctrine_Relation_Association) {
         $q->delete()->from($rel->getAssociationTable()->getComponentName())->where($rel->getLocal() . ' = ?', array_values($this->identifier()));
         if (count($ids) > 0) {
             $q->whereIn($rel->getForeign(), $ids);
         }
         $q->execute();
     } else {
         if ($rel instanceof Doctrine_Relation_ForeignKey) {
             $q->update($rel->getTable()->getComponentName())->set($rel->getForeign(), '?', array(null))->addWhere($rel->getForeign() . ' = ?', array_values($this->identifier()));
             if (count($ids) > 0) {
                 $q->whereIn($rel->getTable()->getIdentifier(), $ids);
             }
             $q->execute();
         }
     }
     if (isset($this->_references[$alias])) {
         foreach ($this->_references[$alias] as $k => $record) {
             if (in_array(current($record->identifier()), $ids)) {
                 $this->_references[$alias]->remove($k);
             }
         }
         $this->_references[$alias]->takeSnapshot();
     }
     return $this;
 }
开发者ID:kirvin,项目名称:the-nerdery,代码行数:39,代码来源:Record.php


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