Answer the question
In order to leave comments, you need to log in
How to get columns in the order they appear in phpMyAdmin?
How to get columns in the order they appear in phpMyAdmin or other CRUD database system?
This is the order in which the columns appear in phpMyAdmin:
id | name | email | password | tables | personal
And this is how they come to me:
id | email | name | password | personal | tables
Source code:
public static function getColumns($table, $database): array
{
return (DB::table('information_schema.columns')
->select(['COLUMN_NAME', 'DATA_TYPE', 'COLUMN_KEY'])
->where('TABLE_NAME', $table)
->where('TABLE_SCHEMA', $database)
->orderByRaw("COLUMN_NAME <> 'id'")
->get()
->toArray());
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question