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


PHP CategoryThread::updateAll方法代码示例

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


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

示例1: testCounterCacheWithSelfJoin

 /**
  * test Counter Cache With Self Joining table
  *
  * @return void
  */
 public function testCounterCacheWithSelfJoin()
 {
     $this->skipIf($this->db instanceof Sqlite, 'SQLite 2.x does not support ALTER TABLE ADD COLUMN');
     $this->loadFixtures('CategoryThread');
     $column = 'COLUMN ';
     if ($this->db instanceof Sqlserver) {
         $column = '';
     }
     $column .= $this->db->buildColumn(array('name' => 'child_count', 'type' => 'integer'));
     $this->db->query('ALTER TABLE ' . $this->db->fullTableName('category_threads') . ' ADD ' . $column);
     $this->db->flushMethodCache();
     $Category = new CategoryThread();
     $result = $Category->updateAll(array('CategoryThread.name' => "'updated'"), array('CategoryThread.parent_id' => 5));
     $this->assertFalse(empty($result));
     $Category = new CategoryThread();
     $Category->belongsTo['ParentCategory']['counterCache'] = 'child_count';
     $Category->updateCounterCache(array('parent_id' => 5));
     $result = Hash::extract($Category->find('all', array('conditions' => array('CategoryThread.id' => 5))), '{n}.CategoryThread.child_count');
     $expected = array(1);
     $this->assertEquals($expected, $result);
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:26,代码来源:ModelWriteTest.php

示例2: testCounterCacheWithSelfJoin

 /**
  * test Counter Cache With Self Joining table
  *
  * @return void
  */
 public function testCounterCacheWithSelfJoin()
 {
     $skip = $this->skipIf($this->db->config['driver'] == 'sqlite', 'SQLite 2.x does not support ALTER TABLE ADD COLUMN');
     if ($skip) {
         return;
     }
     $this->loadFixtures('CategoryThread');
     $this->db->query('ALTER TABLE ' . $this->db->fullTableName('category_threads') . " ADD COLUMN child_count INTEGER");
     $Category = new CategoryThread();
     $result = $Category->updateAll(array('CategoryThread.name' => "'updated'"), array('CategoryThread.parent_id' => 5));
     $this->assertFalse(empty($result));
     $Category = new CategoryThread();
     $Category->belongsTo['ParentCategory']['counterCache'] = 'child_count';
     $Category->updateCounterCache(array('parent_id' => 5));
     $result = Set::extract($Category->find('all', array('conditions' => array('CategoryThread.id' => 5))), '{n}.CategoryThread.child_count');
     $expected = array_fill(0, 1, 1);
     $this->assertEqual($result, $expected);
 }
开发者ID:robotarmy,项目名称:Phog,代码行数:23,代码来源:model_write.test.php


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