getTablesFull() public method

$GLOBALS['dbi']->getTablesFull('my_database'); $GLOBALS['dbi']->getTablesFull('my_database', 'my_table')); $GLOBALS['dbi']->getTablesFull('my_database', 'my_tables_', true));
public getTablesFull ( string $database, string | array $table = '', boolean $tbl_is_group = false, mixed $link = null, integer $limit_offset, boolean | integer $limit_count = false, string $sort_by = 'Name', string $sort_order = 'ASC', string $table_type = null ) : array
$database string database
$table string | array table name(s)
$tbl_is_group boolean $table is a table group
$link mixed mysql link
$limit_offset integer zero-based offset for the count
$limit_count boolean | integer number of tables to return
$sort_by string table attribute to sort by
$sort_order string direction to sort (ASC or DESC)
$table_type string whether table or view
return array list of tables in given db(s)
示例#1
0
 /**
  * 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;
     }
     if (!$is_view) {
         $row_count = $this->_dbi->fetchValue('SELECT COUNT(*) FROM ' . Util::backquote($db) . '.' . 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 ' . Util::backquote($db) . '.' . Util::backquote($table) . ' LIMIT ' . $GLOBALS['cfg']['MaxExactCountViews'], null, 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;
 }