What are some alternative methods for retrieving column flags in SQLite databases?

When working with SQLite databases in PHP, one common method for retrieving column flags is to use the PRAGMA statement with the table_info command. However, an alternative method is to query the sqlite_master table directly to get information about the columns in a table. This can be useful if you need to retrieve additional details about the columns beyond just their flags.

<?php
// Open a connection to the SQLite database
$db = new SQLite3('database.db');

// Query the sqlite_master table to retrieve column information
$query = $db->query("PRAGMA table_info(table_name)");

// Loop through the results and output the column flags
while ($row = $query->fetchArray()) {
    echo "Column Name: " . $row['name'] . "\n";
    echo "Column Type: " . $row['type'] . "\n";
    echo "Not Null: " . $row['notnull'] . "\n";
    echo "Default Value: " . $row['dflt_value'] . "\n";
    echo "Primary Key: " . $row['pk'] . "\n\n";
}

// Close the database connection
$db->close();
?>