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


PHP SelectQuery::addWhereNotIn方法代码示例

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


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

示例1: getParents

 /**
  * Caches the parents (if not cached already)
  * of the given node by fecthing them from the database
  * if neccessary, and then inserting them in <code>_tree</code> and updating
  * <code>_cache</code>.
  * @access public
  * @param object node The node object whose parents we must cache.
  * @return ref array An array of the parent nodes of the given node.
  **/
 function getParents(Node $node)
 {
     // Use Harmoni_Db method for greater performance if it is configured
     if (isset($this->harmoni_db)) {
         return $this->getParents_Harmoni_Db($node);
     }
     // Otherwise use original method
     $idValue = $node->_id->getIdString();
     // if the children have not been already cached, do it
     if (!$this->_isCachedUp($idValue, 1)) {
         // include the given node in the cache of nodes if necessary
         if (!$this->_isCached($idValue)) {
             $nullValue = NULL;
             // getting rid of PHP warnings by specifying
             // this second argument
             $this->_tree->addNode(new TreeNode($idValue), $nullValue);
             $this->_cache[$idValue][0] = $node;
         }
         // now fetch <code>$node</code>'s parents from the database
         // with the exception of those parents that have been already fetched
         $treeNode = $this->_tree->getNode($idValue);
         $nodesToExclude = isset($treeNode) ? $treeNode->getParents() : array();
         $dbHandler = Services::getService("DatabaseManager");
         $idManager = Services::getService("Id");
         $query = new SelectQuery();
         // set the columns to select
         $query->addColumn("id", "id", "parents");
         $query->addColumn("display_name", "display_name", "parents");
         $query->addColumn("description", "description", "parents");
         $query->addColumn("domain", "domain", "az2_node_type");
         $query->addColumn("authority", "authority", "az2_node_type");
         $query->addColumn("keyword", "keyword", "az2_node_type");
         $query->addColumn("description", "type_description", "az2_node_type");
         // set the tables
         $query->addTable("az2_j_node_node", NO_JOIN, "", "child");
         $joinc = "child.fk_parent = " . "parents.id";
         $query->addTable("az2_node", INNER_JOIN, $joinc, "parents");
         $joinc = "parents.fk_type = " . "az2_node_type.id";
         $query->addTable("az2_node_type", INNER_JOIN, $joinc);
         $query->addWhereEqual("child.fk_hierarchy", $this->_hierarchyId);
         $query->addWhereEqual("child.fk_child", $idValue);
         $query->addOrderBy("parents.id");
         if (count($nodesToExclude) > 0) {
             $query->addWhereNotIn("parents.id", array_keys($nodesToExclude));
         }
         //			echo "<pre>\n";
         //			echo MySQL_SQLGenerator::generateSQLQuery($query);
         //			echo "</pre>\n";
         $queryResult = $dbHandler->query($query, $this->_dbIndex);
         // for all rows returned by the query
         while ($queryResult->hasMoreRows()) {
             $row = $queryResult->getCurrentRow();
             // see if node in current row is in the cache
             $parentIdValue = $row['id'];
             // if not create it and cache it
             if (!$this->_isCached($parentIdValue)) {
                 $parentId = $idManager->getId($parentIdValue);
                 $parentType = new HarmoniType($row['domain'], $row['authority'], $row['keyword'], $row['type_description']);
                 $parent = new AuthZ2_Node($parentId, $parentType, $row['display_name'], $row['description'], $this);
                 $parentTreeNode = new TreeNode($parentIdValue);
                 $nullValue = NULL;
                 // getting rid of PHP warnings by specifying
                 // this second argument
                 $this->_tree->addNode($parentTreeNode, $nullValue);
                 $this->_tree->addNode($treeNode, $parentTreeNode);
                 $this->_cache[$parentIdValue][0] = $parent;
                 $this->_cache[$parentIdValue][1] = 0;
                 $this->_cache[$parentIdValue][2] = 0;
             } else {
                 $this->_tree->addNode($treeNode, $this->_tree->getNode($parentIdValue));
             }
             $queryResult->advanceRow();
         }
         // finish caching
         $this->_cache[$idValue][2] = 1;
         // parents have been cached
         $queryResult->free();
     }
     // now that all nodes are cached, just return all children
     $treeNode = $this->_tree->getNode($idValue);
     $result = array();
     $parentsIds = $treeNode->getParents();
     foreach (array_keys($parentsIds) as $i => $key) {
         $result[] = $this->_cache[$key][0];
     }
     return $result;
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:96,代码来源:HierarchyCache.class.php


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