06/08/2012 12:15 a.m.
On MySQL, field_len for MEMO returns 16777215.
|
Returns information on the structure of database tables.
Different syntax is used for dBase3 and MySQL databases. AttributesFor xBase3Creates a database that contains information about the structure of the source database. The newly created database contains one record for each field in the source database. There will be one record in this database for each field definition corresponding to the field definitions used in the <MvCREATE> tag that created the source database. This new database is not opened. To access information in the new database, you must open it.
For MySQLReturns a structured array that contains information about the structure of the source database table. The array contains one element for each field in the source database.
Data FormatEach record or array element will contain the following fields:
ExamplesThis example illustrates the basic syntax for xBase3 databases. xBase3:<MvREVEALSTRUCTURE NAME = "alias" DATABASE = "struct.dbf"> This script will display the structure of the employees database. xBase3:<MvOPEN NAME = "employees" DATABASE = "{ g.filename }"> <MvREVEALSTRUCTURE NAME = "employees" DATABASE = "struct.dbf"> <MvOPEN NAME = "struct" DATABASE = "struct.dbf"> <MvWHILE EXPR = "{ NOT struct.d.EOF }"> <MvEVAL EXPR = "{ struct.d.field_name }">, <MvEVAL EXPR = "{ struct.d.field_type }">, <MvEVAL EXPR = "{ struct.d.field_len}">, <MvEVAL EXPR = "{ struct.d.field_dec }"><br> <MvSKIP NAME = "struct" ROWS = 1> </MvWHILE> <MvCLOSE NAME = "struct"> <MvCLOSE NAME = "employees"> For MySQLThis example illustrates the basic syntax for MySQL databases. MySQL:<MvREVEALSTRUCTURE NAME="{ l.database_name }" VIEW = "{ l.table }" VARIABLE="l.struc"> This script displays the structure of the s01_Products database in Miva Merchant. MySQL:<MvASSIGN NAME="l.database" VALUE="Merchant"> <MvASSIGN NAME="l.table" VALUE="s01_Products"> <MvOPENVIEW NAME="{ l.database }" VIEW="{ l.table }" QUERY="{ 'SELECT * FROM ' $ l.table $ ' LIMIT 0,1' }"> <MvREVEALSTRUCTURE NAME="{ l.database }" VIEW = "{ l.table }" VARIABLE="l.struc"> table = <MvEVAL EXPR="{ l.table }"><br> <b><u>field_dec, field_len, field_name, field_type</u></b><br> <MvASSIGN NAME="l.posn" VALUE="{ 1 }"> <MvREFERENCE NAME = "l.item" VARIABLE = "{ 'l.struc[' $ l.posn $ ']' }"> <MvWHILE EXPR="{ l.item }"> <MvEVAL EXPR="{ l.item:field_dec }">, <MvEVAL EXPR="{ l.item:field_len }">, <MvEVAL EXPR="{ l.item:field_name }">, <MvEVAL EXPR="{ l.item:field_type }"><br> <MvASSIGN NAME="l.posn" VALUE="{ l.posn + 1 }"> <MvREFERENCE NAME = "l.item" VARIABLE = "{ 'l.struc[' $ l.posn $ ']' }"> </MvWHILE> <MvASSIGN NAME="g.columns" VALUE="{ l.struc }"> <MvCLOSEVIEW Name="{ l.database }" VIEW ="{ l.table }"> This example displays all the tables in the Miva Merchant database. MySQL:<MvOPENVIEW NAME = "Merchant" VIEW = "Tables" QUERY = "SHOW TABLES"> <MvIF EXPR = "{ NOT Tables.d.EOF }"> <MvREVEALSTRUCTURE NAME = "Merchant" VIEW = "Tables" VARIABLE = "l.columns"> <MvASSIGN NAME="g.columns" VALUE="{ l.columns }"> <MvWHILE EXPR = "{ NOT Tables.d.EOF }"> <MvEVAL EXPR="{ miva_variable_value( 'Tables.d.' $ l.columns[ 1 ]:field_name ) $ ' <br>' }"> <MvSKIP NAME = "Merchant" VIEW = "Tables" ROWS = 1> </MvWHILE> </MvIF> <MvCLOSEVIEW Name="Merchant" VIEW ="Tables">
User Annotations:
MvREVEALSTRUCTURE
Gordon Currie
: gordon at, phosphormedia d0t com
06/08/2012 12:15 a.m. On MySQL, field_len for MEMO returns 16777215.
Gordon Currie
: gordon at, phosphormedia d0t com
06/08/2012 11:58 a.m. Under MySQL, a Boolean (tinyint) field returns a B, not an L as described. |