GetColumnNames() public method

Returns the field names in a table or query in an array
public GetColumnNames ( string $table = "" ) : array
$table string (Optional) If a table name is not specified, the last returned records are used
return array An array that contains the column names
Example #1
0
    echo $row->Color . " - " . $row->Age . "<br />\n";
}
// --- Loop through the records with an index -----------------------
for ($index = 0; $index < $db->RowCount(); $index++) {
    $row = $db->Row($index);
    echo "Row " . $index . ":" . $row->Color . " - " . $row->Age . "<br />\n";
}
// --- We can even grab array data from the last result set ---------
$myArray = $db->RecordsArray();
// --- List all of the tables in the database -----------------------
$tables = $db->GetTables();
foreach ($tables as $table) {
    echo $table . "<br />\n";
}
// --- Show the columns (field names) in a table --------------------
$columns = $db->GetColumnNames("test");
foreach ($columns as $column) {
    echo $column . "<br />\n";
}
// --- Find a column (field) type and length ------------------------
echo "Type: " . $db->GetColumnDataType("Color", "Test") . "<br />\n";
echo "Length: " . $db->GetColumnLength("Color", "Test") . "<br />\n";
// --- Get a column's ordinal position (the column number) ----------
echo $db->GetColumnID("Age", "Test") . "<br />\n";
// --- Check for errors ---------------------------------------------
if ($db->Error()) {
    echo "<h3>" . $db->Error() . "</h3>\n";
} else {
    echo "<p>There were no errors</p>\n";
}
// --- Format some values ready for SQL -----------------------------