PMA\libraries\DatabaseInterface::getTableIndexesSql PHP Метод

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

Returns SQL for fetching information on table indexes (SHOW INDEXES)
public getTableIndexesSql ( string $database, string $table, string $where = null ) : string
$database string name of database
$table string name of the table whose indexes are to be retrieved
$where string additional conditions for WHERE
Результат string SQL for getting indexes
    public function getTableIndexesSql($database, $table, $where = null)
    {
        $sql = 'SHOW INDEXES FROM ' . Util::backquote($database) . '.' . Util::backquote($table);
        if ($where) {
            $sql .= ' WHERE (' . $where . ')';
        }
        return $sql;
    }

Usage Example

Пример #1
0
 /**
  * Get all indexed columns
  *
  * returns an array with all columns that make use of an index
  *
  * e.g. index(col1, col2) would return col1, col2
  *
  * @param bool $backquoted whether to quote name with backticks ``
  * @param bool $fullName   whether to include full name of the table as a prefix
  *
  * @return array
  */
 public function getIndexedColumns($backquoted = true, $fullName = true)
 {
     $sql = $this->_dbi->getTableIndexesSql($this->getDbName(), $this->getName(), '');
     $indexed = $this->_dbi->fetchResult($sql, 'Column_name', 'Column_name');
     $return = array();
     foreach ($indexed as $column) {
         $return[] = ($fullName ? $this->getFullName($backquoted) . '.' : '') . ($backquoted ? Util::backquote($column) : $column);
     }
     return $return;
 }
All Usage Examples Of PMA\libraries\DatabaseInterface::getTableIndexesSql