vendredi 24 avril 2015

PHP, SQLite query, result in JSON with field type and size

I need a PHP script that execute a query in SQLite DB and return data in json format. I have created this very simple script:

<?php

    $db = new SQLite3('collection.s3db');
    $results = $db->query('SELECT * FROM movies');

    $out = array();
    while ($row = $results->fetchArray(SQLITE_ASSOC)) {
        $out[] = $row;
    }
    echo json_encode($out);
?>

result is OK, but i need also the field type and field size of returned data.

I have found in "SQLite3Result class" the method "columnType" that return field type but there is not method for field size. How can i get this information?

Aucun commentaire:

Enregistrer un commentaire