px_get_schema
(PECL paradox:1.0-1.4.1)
px_get_schema — Returns the database schema
Описание
px_get_schema() returns the database schema.
Список параметров
- pxdoc
-
Resource identifier of the paradox database as returned by px_new().
- mode
-
If the optional mode is PX_KEYTOLOWER or PX_KEYTOUPPER the keys of the returned array will be converted to lower or upper case. If mode is 0 or not passed at all, then the key name will be identical to the field name.
Возвращаемые значения
Returns the schema of a database file as an associated array. The key name is equal to the field name. Each array element is itself an associated array containing the two fields type and size. type is one of the constants in table Constants for field types. size is the number of bytes this field consumes in the record. The total of all field sizes is equal to the record size as it can be retrieved with px-get-info().
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения для работы с базами данных
- Расширения для работы с базами данных отдельных производителей
- Paradox File Access
- px_close
- px_create_fp
- px_date2string
- px_delete_record
- px_delete
- px_get_field
- px_get_info
- px_get_parameter
- px_get_record
- px_get_schema
- px_get_value
- px_insert_record
- px_new
- px_numfields
- px_numrecords
- px_open_fp
- px_put_record
- px_retrieve_record
- px_set_blob_file
- px_set_parameter
- px_set_tablename
- px_set_targetencoding
- px_set_value
- px_timestamp2string
- px_update_record
Коментарии
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";
}
?>