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


PHP SelectQuery::setColumns方法代码示例

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


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

示例1: foreach

 /**
  * Sychronize the cache. Remove any nodes from the cache whose AZs may have 
  * changed.
  * 
  * @return void
  * @access public
  * @since 12/20/05
  */
 function _synchronizeCache()
 {
     $dbHandler = Services::getService("DBHandler");
     foreach (array_keys($_SESSION['__isAuthorizedCacheAgents']) as $agentIdString) {
         // Select the nodeIds who's authorization situation may have changed
         // since the cache was last synchronized. Clear these Ids from the cache.
         $query = new SelectQuery();
         $query->addTable("az2_node");
         $query->setColumns(array("id"));
         $dbDate = $dbHandler->toDBDate($_SESSION['__isAuthorizedCacheTime'][$agentIdString], $this->_configuration->getProperty('database_index'));
         $query->addWhere("last_changed > " . $dbDate);
         // 		printpre(MySQL_SQLGenerator::generateSQLQuery($query));
         $result = $dbHandler->query($query, $this->_configuration->getProperty('database_index'));
         while ($result->hasMoreRows()) {
             unset($_SESSION['__isAuthorizedCache'][$agentIdString][$result->field("id")]);
             $result->advanceRow();
         }
         $result->free();
         $_SESSION['__isAuthorizedCacheTime'][$agentIdString] = DateAndTime::now();
     }
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:29,代码来源:IsAuthorizedCache.class.php

示例2: Queue

 function test_All_Queries()
 {
     $value = "'Depeche Mode rocks!'";
     $this->dbhandler->connect();
     // create a new queue of queries to execuete
     $queryQueue = new Queue();
     $query = new InsertQuery();
     $query->setTable("test1");
     $query->setColumns(array("value"));
     $query->addRowOfValues(array($value));
     $queryQueue->add($query);
     $query = new InsertQuery();
     $query->setTable("test1");
     $query->setColumns(array(id, value));
     $query->addRowOfValues(array("3000000", $value));
     $queryQueue->add($query);
     $query = new DeleteQuery();
     $query->setTable("test1");
     $query->setWhere("id = 3000000");
     $queryQueue->add($query);
     $query = new UpdateQuery();
     $query->setTable("test1");
     $query->setColumns(array("value"));
     $query->setValues(array($value));
     $query->setWhere("id > 1000 AND id < 1006");
     $queryQueue->add($query);
     $resultQueue = $this->dbhandler->queryQueue($queryQueue);
     $this->assertEqual($this->dbhandler->getTotalNumberOfQueries(), 4);
     $this->assertEqual($this->dbhandler->getTotalNumberOfSuccessfulQueries(), 4);
     $this->assertEqual($this->dbhandler->getTotalNumberOfFailedQueries(), 0);
     $result = $resultQueue->next();
     $this->assertEqual($result->getNumberOfRows(), 1);
     $this->assertNotNull($result->getLastAutoIncrementValue());
     $id = $result->getLastAutoIncrementValue();
     $result = $resultQueue->next();
     $this->assertEqual($result->getNumberOfRows(), 1);
     $this->assertNotNull($result->getLastAutoIncrementValue());
     $result = $resultQueue->next();
     $this->assertEqual($result->getNumberOfRows(), 1);
     $result = $resultQueue->next();
     $query = new SelectQuery();
     $query->setColumns(array("value"));
     $query->addTable("test1");
     $query->setWhere("id = {$id}");
     $result = $this->dbhandler->query($query);
     $this->assertEqual($this->dbhandler->getTotalNumberOfQueries(), 5);
     $this->assertEqual($this->dbhandler->getTotalNumberOfSuccessfulQueries(), 5);
     $this->assertEqual($this->dbhandler->getTotalNumberOfFailedQueries(), 0);
     $this->assertEqual("'" . $result->field("value") . "'", $value);
     $result->free();
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:51,代码来源:DBHandlerTestCase.class.php


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