downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

px_get_value> <px_get_record
[edit] Last updated: Wed, 22 May 2013

view this page in

px_get_schema

(PECL paradox >= 1.0.0)

px_get_schemaデータベーススキーマを返す

説明

array px_get_schema ( resource $pxdoc [, int $mode = 0 ] )

px_get_schema() は、データベーススキーマを返します。

パラメータ

pxdoc

px_new() が返す、 paradox データベースのリソース ID。

mode

返される配列のキーを小文字または大文字に変換するために、 オプションの modePX_KEYTOLOWER あるいは PX_KEYTOUPPER を指定することができます。mode が渡されなかったりあるいは 0 であった場合は、 キーはフィールド名そのものとなります。

返り値

データベースファイルのスキーマを連想配列で返します。 キーの名前はフィールド名と等しくなります。 配列の各要素もまた連想配列となっており、2 つのフィールド type および size が含まれます。type は、 フィールド型の定数 の中のいずれかです。 size は、レコード内でこのフィールドが使用するバイト数です。 すべてのフィールドのサイズを合計したものが、 px-get-info() で得られるレコードサイズと等しくなります。



add a note add a note User Contributed Notes px_get_schema - [1 notes]
up
0
Mr Muddy
5 years ago
It's not especially pretty and there isn't any error trapping, so please don't use this on any sort of production data.  This will display the schema of a paradox data source.... 

<?
    /*
    Paradox database schema display
    Tim Burt
    27/07/07
    */

    //we're expecting a filename in the post vars
    if ($_POST['database_name'] != "") {
       
        //Set up anything we are likely to need
        $database_filename = "<path to your data file>".$_POST['database_name'];
       
        echo "<p><b>Schema for ".$_POST['database_name']."</b></p>\n";
       
        if(!$pxdoc = px_new()) {
      DIE("Problem !");
        }
        $fp = fopen($database_filename, "r");
        if(!px_open_fp($pxdoc, $fp)) {
         DIE("Couldn't open database file");
        }
        else {       
            //output the database schema...
            $stock_schema = px_get_schema($pxdoc);
           
            if (is_array($stock_schema)) {
                foreach ($stock_schema as $key=>$value) {
                    echo "<br><b>".$key."</b> - Type ".$value['type'];
                    }
                }
            }
        px_close($pxdoc);
        px_delete($pxdoc);
        fclose($fp);       
       
    }
    else {
        //show the form to get the filename
        echo "<form action=\"show_schema.php\" method=\"post\">\n";
        echo "<p>Data Source Name (include extension) : <input type=\"text\" size=\"10\" name=\"database_name\"></p>\n";
        echo "<p><input type=\"submit\" value=\"Show Schema !\">\n";
        echo "</form>\n";
    }   

?>

 
show source | credits | sitemap | contact | advertising | mirror sites