I was reading through our code base at my company and I saw something that seemed like it could be done better.
$dbRow = $dbh->Execute("SELECT * FROM database.table LIMIT 1");
$tableColumnCount = $dbRow->_numOfFields;
Is this the only way to get a column count using ADODB? It just seems silly to have to execute a query so you can ask the question.
You can use the INFORMATION_SCHEMA.COLUMNS table:
That said, you might want to run the
FLUSH TABLEScommand prior to for the INFORMATION_SCHEMA.COLUMNS to reflect existing tables and columns because the data is cached.