Getting information about databases and tables
Previous  Next

It is possible to get general informations about the database and its tables; we have already seen how to use SHOW in the previous tutorials Using databases and Using tables.

Now let's see an example on how to get specific informations about the tables' structure.

<?php
            include 'gladius/gladius.php';
            
            $G = new Gladius();

            $G->SelectDB('full_path_to_db/database_name/') or die($G->errstr);
            
            // query a description for table phonebook
            $rs = $G->Query('DESCRIBE phonebook');
            
            // print the table description
            print_r($rs->GetArray());
?>

The output will be:

Array
(
    [0] => Array
        (
            [field] => NAME
            [type] => VARCHAR(200)
            [null] => YES
            [key] =>
            [default] =>
            [extra] =>
        )
    [1] => Array
        (
            [field] => SURNAME
            [type] => VARCHAR(200)
            [null] => YES
            [key] =>
            [default] =>
            [extra] =>
        )
    [2] => Array
        (
            [field] => PHONE
            [type] => VARCHAR(100)
            [null] => YES
            [key] =>
            [default] =>
            [extra] =>
        )

)