views:

37

answers:

1

now I use:

PRAGMA table_info(table_name)

construct, but it don't allow me to narrow search result to only column names, as it turns out much of unwanted data. That is array of arrays

Array
(
    [0] => Array
        (
            [cid] => 0
            [name] => id
            [type] => INTEGER
            [notnull] => 0
            [dflt_value] => 
            [pk] => 1
        )

    [1] => Array
        (
            [cid] => 1
            [name] => name
            [type] => TEXT
            [notnull] => 0
            [dflt_value] => 
            [pk] => 0
        )

    [2] => Array
        (
            [cid] => 2
            [name] => timestamp
            [type] => INTEGER
            [notnull] => 0
            [dflt_value] => 
            [pk] => 0
        )

    [3] => Array
        (
            [cid] => 3
            [name] => note
            [type] => TEXT
            [notnull] => 0
            [dflt_value] => 
            [pk] => 0
        )

)

it would be better for the result to be

Array
(
    [0] => id
    [1] => title
    [2] => timestamp
    [3] => note
)

but SELECT name from PRAGMA table_info(table_name) doesn't work

+1  A: 

You can't change the output of table_info, but it's trivial to loop over your result object and build the array of column names you want.

Fo