Create a new table
Prototype:
This function create a new table with couple of files .idx and .dat with name $dbfile. The table is setup with lenght of record specified by $rec_len and with primary key $primary_key. An optional argument $db_flags permit you to specify flags relating lock modes etc…
Database Flags
| MFC_VARLEN | Sets table with variable record length |
|---|---|
| MFC_FIXLEN | Sets table with fixed record length |
RETURN: This function returns a resource to the handle of table or FALSE if some error occurred. In this case you can get string error code using mfcdb_error()
<?php $keyResource = mfcdb_key(MFC_ISNODUPS, 1, 0, 18, MFC_CHARTYPE); if($keyResource == FALSE) { die("Error creating key."); } $resource = mfcdb_create("mydatabase", 47, $keyResource); if($resource == FALSE) { die("An error occurred creating table, error is: ".mfcdb_error()."\n"); } $record = "0101001Test record length n bytes"); $record = sprintf("%47s", $record); $result = mfcdb_insert($resource, $record); if($result == FALSE) { echo "An error occurred while inserting record, error is: ".mfcdb_error()."\n"; } else { echo "Inserted record ".$result."\n"; } if(mfcdb_close($resource) == FALSE) { die("An error occurred closing table, error is: ".mfcdb_error()."\n"); } ?>