PMA\libraries\navigation\nodes\NodeDatabase::getPresence PHP Метод

getPresence() публичный Метод

Returns the number of children of type $type present inside this container This method is overridden by the PMA\libraries\navigation\nodes\NodeDatabase and PMA\libraries\navigation\nodes\NodeTable classes
public getPresence ( string $type = '', string $searchClause = '', boolean $singleItem = false ) : integer
$type string The type of item we are looking for ('tables', 'views', etc)
$searchClause string A string used to filter the results of the query
$singleItem boolean Whether to get presence of a single known item or false in none
Результат integer
    public function getPresence($type = '', $searchClause = '', $singleItem = false)
    {
        $retval = 0;
        switch ($type) {
            case 'tables':
                $retval = $this->_getTableCount($searchClause, $singleItem);
                break;
            case 'views':
                $retval = $this->_getViewCount($searchClause, $singleItem);
                break;
            case 'procedures':
                $retval = $this->_getProcedureCount($searchClause, $singleItem);
                break;
            case 'functions':
                $retval = $this->_getFunctionCount($searchClause, $singleItem);
                break;
            case 'events':
                $retval = $this->_getEventCount($searchClause, $singleItem);
                break;
            default:
                break;
        }
        return $retval;
    }

Usage Example

Пример #1
0
 /**
  * Adds containers to a node that is a database
  *
  * References to existing children are returned
  * if this function is called twice on the same node
  *
  * @param NodeDatabase $db   The database node, new containers will be
  *                           attached to this node
  * @param string       $type The type of item being paginated on
  *                           the second level of the tree
  * @param int          $pos2 The position for the pagination of
  *                           the branch at the second level of the tree
  *
  * @return array An array of new nodes
  */
 private function _addDbContainers($db, $type, $pos2)
 {
     // Get items to hide
     $hidden = $db->getHiddenItems('group');
     if (!$GLOBALS['cfg']['NavigationTreeShowTables'] && !in_array('tables', $hidden)) {
         $hidden[] = 'tables';
     }
     if (!$GLOBALS['cfg']['NavigationTreeShowViews'] && !in_array('views', $hidden)) {
         $hidden[] = 'views';
     }
     if (!$GLOBALS['cfg']['NavigationTreeShowFunctions'] && !in_array('functions', $hidden)) {
         $hidden[] = 'functions';
     }
     if (!$GLOBALS['cfg']['NavigationTreeShowProcedures'] && !in_array('procedures', $hidden)) {
         $hidden[] = 'procedures';
     }
     if (!$GLOBALS['cfg']['NavigationTreeShowEvents'] && !in_array('events', $hidden)) {
         $hidden[] = 'events';
     }
     $retval = array();
     if ($db->hasChildren(true) == 0) {
         if (!in_array('tables', $hidden) && $db->getPresence('tables')) {
             $retval['tables'] = NodeFactory::getInstance('NodeTableContainer');
         }
         if (!in_array('views', $hidden) && $db->getPresence('views')) {
             $retval['views'] = NodeFactory::getInstance('NodeViewContainer');
         }
         if (!in_array('functions', $hidden) && $db->getPresence('functions')) {
             $retval['functions'] = NodeFactory::getInstance('NodeFunctionContainer');
         }
         if (!in_array('procedures', $hidden) && $db->getPresence('procedures')) {
             $retval['procedures'] = NodeFactory::getInstance('NodeProcedureContainer');
         }
         if (!in_array('events', $hidden) && $db->getPresence('events')) {
             $retval['events'] = NodeFactory::getInstance('NodeEventContainer');
         }
         // Add all new Nodes to the tree
         foreach ($retval as $node) {
             if ($type == $node->real_name) {
                 $node->pos2 = $pos2;
             }
             $db->addChild($node);
         }
     } else {
         foreach ($db->children as $node) {
             if ($type == $node->real_name) {
                 $node->pos2 = $pos2;
             }
             $retval[$node->real_name] = $node;
         }
     }
     return $retval;
 }