/**
  * Counts and returns (or displays) the number of records in a table
  *
  * @param bool $force_exact whether to force an exact count
  *
  * @return mixed the number of records if "retain" param is true,
  *               otherwise true
  */
 public function countRecords($force_exact = false)
 {
     $is_view = $this->isView();
     $db = $this->_db_name;
     $table = $this->_name;
     if ($this->_dbi->getCachedTableContent("{$db}.{$table}.ExactRows") != null) {
         $row_count = $this->_dbi->getCachedTableContent("{$db}.{$table}.ExactRows");
         return $row_count;
     }
     $row_count = false;
     if (!$force_exact) {
         if ($this->_dbi->getCachedTableContent("{$db}.{$table}.Rows") == null && !$is_view) {
             $tmp_tables = $this->_dbi->getTablesFull($db, $table);
             if (isset($tmp_tables[$table])) {
                 $this->_dbi->cacheTableContent("{$db}.{$table}", $tmp_tables[$table]);
             }
         }
         if ($this->_dbi->getCachedTableContent("{$db}.{$table}.Rows") != null) {
             $row_count = $this->_dbi->getCachedTableContent("{$db}.{$table}.Rows");
         } else {
             $row_count = false;
         }
     }
     // for a VIEW, $row_count is always false at this point
     if (false !== $row_count && $row_count >= $GLOBALS['cfg']['MaxExactCount']) {
         return $row_count;
     }
     // Make an exception for views in I_S and D_D schema in
     // Drizzle, as these map to in-memory data and should execute
     // fast enough
     if (!$is_view || PMA_DRIZZLE && $this->_dbi->isSystemSchema($db)) {
         $row_count = $this->_dbi->fetchValue('SELECT COUNT(*) FROM ' . PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table));
     } else {
         // For complex views, even trying to get a partial record
         // count could bring down a server, so we offer an
         // alternative: setting MaxExactCountViews to 0 will bypass
         // completely the record counting for views
         if ($GLOBALS['cfg']['MaxExactCountViews'] == 0) {
             $row_count = 0;
         } else {
             // Counting all rows of a VIEW could be too long,
             // so use a LIMIT clause.
             // Use try_query because it can fail (when a VIEW is
             // based on a table that no longer exists)
             $result = $this->_dbi->tryQuery('SELECT 1 FROM ' . PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table) . ' LIMIT ' . $GLOBALS['cfg']['MaxExactCountViews'], null, PMA_DatabaseInterface::QUERY_STORE);
             if (!$this->_dbi->getError()) {
                 $row_count = $this->_dbi->numRows($result);
                 $this->_dbi->freeResult($result);
             }
         }
     }
     if ($row_count) {
         $this->_dbi->cacheTableContent("{$db}.{$table}.ExactRows", $row_count);
     }
     return $row_count;
 }