oscarotero / simple-crud

PHP library to provide magic CRUD in MySQL/Sqlite databases with zero configuration
MIT License
242 stars 58 forks source link

Is it possible to select column names? #27

Closed elieobeid7 closed 6 years ago

elieobeid7 commented 6 years ago

Is it possible to select column names from a table, something like

SELECT `COLUMN_NAME` 
FROM `INFORMATION_SCHEMA`.`COLUMNS` 
WHERE `TABLE_SCHEMA`='tablename' 
    AND `TABLE_NAME`='tablename';
oscarotero commented 6 years ago

You can get the full scheme of the database (all tables and columns) with the getScheme() method:

$scheme = $db->getScheme();

$fieldsNames = array_keys($scheme['tablename']['fields']);
elieobeid7 commented 6 years ago

'Warning: array_keys() expects parameter 1 to be array, null given'

anyway ill close this issue, coz its not that important, i ended up writing the column names by hand in array. I dont want to waste your time on this one