2020-10-27, 11:22 AM
The function
For
For
IMO we could use the skeleton of MySQL's
show_fields_from($table)
that shows the "show fields from" command for a specific table returns results in different formats for different db engines. It makes some particular uses of this function fail, for example, the merge system's column length calculation (https://github.com/mybb/merge-system/pull/260 ).For
mysql
(now deprecated) and mysqli
, the method directly uses SQL SHOW FIELDS FROM table_name
to query, the results have columns (on MySQL 5.7) "Field", "Type", "Null", "Key", "Default", "Extra" and returns them.mysql
: https://github.com/mybb/mybb/blob/mybb_1....php#L1111mysqli
: https://github.com/mybb/mybb/blob/mybb_1....php#L1105For
pqsql
and sqlite
, the method uses some different SQL queries to get an intermediate result and reformat it as the final results that have columns "Field", "Extra" and returns them. It's worth noting that the two methods have different results in the "Extra" field. For pgsql
, the information of column types is totally forgotten.pqsql
: https://github.com/mybb/mybb/blob/mybb_1....php#L1134sqlite
: https://github.com/mybb/mybb/blob/mybb_1...e.php#L954IMO we could use the skeleton of MySQL's
SHOW FIELDS FROM
's result to format results of pqsql
and sqlite
.