當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Criteria::doUpdate方法代碼示例

本文整理匯總了PHP中Propel\Runtime\ActiveQuery\Criteria::doUpdate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Criteria::doUpdate方法的具體用法?PHP Criteria::doUpdate怎麽用?PHP Criteria::doUpdate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Propel\Runtime\ActiveQuery\Criteria的用法示例。


在下文中一共展示了Criteria::doUpdate方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testDoUpdate

 public function testDoUpdate()
 {
     try {
         $c1 = new Criteria();
         $c1->setPrimaryTableName(BookTableMap::TABLE_NAME);
         $c1->add(BookTableMap::ID, 12, ' BAD SQL');
         $c2 = new Criteria();
         $c2->add(BookTableMap::TITLE, 'Foo');
         $c1->doUpdate($c2, Propel::getServiceContainer()->getWriteConnection(BookTableMap::DATABASE_NAME));
         $this->fail('Missing expected exception on BAD SQL');
     } catch (PropelException $e) {
         $this->assertContains($this->getSql('[UPDATE `book` SET `TITLE`=:p1 WHERE book.ID BAD SQL:p2]'), $e->getMessage(), 'SQL query is written in the exception message');
     }
 }
開發者ID:kalaspuffar,項目名稱:php-orm-benchmark,代碼行數:14,代碼來源:TableMapExceptionsTest.php

示例2: testCommentDoUpdate

 public function testCommentDoUpdate()
 {
     $c1 = new Criteria();
     $c1->setPrimaryTableName(BookTableMap::TABLE_NAME);
     $c1->setComment('Foo');
     $c2 = new Criteria();
     $c2->add(BookTableMap::COL_TITLE, 'Updated Title');
     $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
     $c1->doUpdate($c2, $con);
     $expected = $this->getSql('UPDATE /* Foo */ `book` SET `TITLE`=\'Updated Title\'');
     $this->assertEquals($expected, $con->getLastExecutedQuery(), 'Criteria::setComment() adds a comment to update queries');
 }
開發者ID:bondarovich,項目名稱:Propel2,代碼行數:12,代碼來源:TableMapTest.php

示例3: shiftLevel

 /**
  * Adds $delta to level for nodes having left value >= $first and right value <= $last.
  * '$delta' can also be negative.
  *
  * @param      int $delta        Value to be shifted by, can be negative
  * @param      int $first        First node to be shifted
  * @param      int $last            Last node to be shifted
  * @param      ConnectionInterface $con        Connection to use.
  */
 public static function shiftLevel($delta, $first, $last, ConnectionInterface $con = null)
 {
     if ($con === null) {
         $con = Propel::getServiceContainer()->getWriteConnection(CategoryTableMap::DATABASE_NAME);
     }
     $whereCriteria = new Criteria(CategoryTableMap::DATABASE_NAME);
     $whereCriteria->add(ChildCategory::LEFT_COL, $first, Criteria::GREATER_EQUAL);
     $whereCriteria->add(ChildCategory::RIGHT_COL, $last, Criteria::LESS_EQUAL);
     $valuesCriteria = new Criteria(CategoryTableMap::DATABASE_NAME);
     $valuesCriteria->add(ChildCategory::LEVEL_COL, array('raw' => ChildCategory::LEVEL_COL . ' + ?', 'value' => $delta), Criteria::CUSTOM_EQUAL);
     $whereCriteria->doUpdate($valuesCriteria, $con);
 }
開發者ID:mtornero,項目名稱:slowshop,代碼行數:21,代碼來源:CategoryQuery.php

示例4: sortableShiftRank

 /**
  * Adds $delta to all Rank values that are >= $first and <= $last.
  * '$delta' can also be negative.
  *
  * @param      int $delta Value to be shifted by, can be negative
  * @param      int $first First node to be shifted
  * @param      int $last  Last node to be shifted
  * @param      ConnectionInterface $con Connection to use.
  */
 public static function sortableShiftRank($delta, $first, $last = null, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(WorkTableMap::DATABASE_NAME);
     }
     $whereCriteria = new Criteria(WorkTableMap::DATABASE_NAME);
     $criterion = $whereCriteria->getNewCriterion(WorkTableMap::RANK_COL, $first, Criteria::GREATER_EQUAL);
     if (null !== $last) {
         $criterion->addAnd($whereCriteria->getNewCriterion(WorkTableMap::RANK_COL, $last, Criteria::LESS_EQUAL));
     }
     $whereCriteria->add($criterion);
     $valuesCriteria = new Criteria(WorkTableMap::DATABASE_NAME);
     $valuesCriteria->add(WorkTableMap::RANK_COL, array('raw' => WorkTableMap::RANK_COL . ' + ?', 'value' => $delta), Criteria::CUSTOM_EQUAL);
     $whereCriteria->doUpdate($valuesCriteria, $con);
     WorkTableMap::clearInstancePool();
 }
開發者ID:sam-higton,項目名稱:spoiler-wiki,代碼行數:25,代碼來源:WorkQuery.php


注:本文中的Propel\Runtime\ActiveQuery\Criteria::doUpdate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。