PMA\libraries\navigation\nodes\NodeDatabase::_getTableOrViewCount PHP Method

_getTableOrViewCount() private method

Returns the number of tables or views present inside this database
private _getTableOrViewCount ( string $which, string $searchClause, boolean $singleItem ) : integer
$which string tables|views
$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
return integer
    private function _getTableOrViewCount($which, $searchClause, $singleItem)
    {
        $db = $this->real_name;
        if ($which == 'tables') {
            $condition = '=';
        } else {
            $condition = '!=';
        }
        if (!$GLOBALS['cfg']['Server']['DisableIS']) {
            $db = $GLOBALS['dbi']->escapeString($db);
            $query = "SELECT COUNT(*) ";
            $query .= "FROM `INFORMATION_SCHEMA`.`TABLES` ";
            $query .= "WHERE `TABLE_SCHEMA`='{$db}' ";
            $query .= "AND `TABLE_TYPE`" . $condition . "'BASE TABLE' ";
            if (!empty($searchClause)) {
                $query .= "AND " . $this->_getWhereClauseForSearch($searchClause, $singleItem, 'TABLE_NAME');
            }
            $retval = (int) $GLOBALS['dbi']->fetchValue($query);
        } else {
            $query = "SHOW FULL TABLES FROM ";
            $query .= Util::backquote($db);
            $query .= " WHERE `Table_type`" . $condition . "'BASE TABLE' ";
            if (!empty($searchClause)) {
                $query .= "AND " . $this->_getWhereClauseForSearch($searchClause, $singleItem, 'Tables_in_' . $db);
            }
            $retval = $GLOBALS['dbi']->numRows($GLOBALS['dbi']->tryQuery($query));
        }
        return $retval;
    }