PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Dave Smith   PHP CSV to Data Dictionary   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example Usage
Class: PHP CSV to Data Dictionary
Generate data dictionary from CSV file
Author: By
Last change:
Date: 9 years ago
Size: 1,025 bytes
 

Contents

Class file image Download
<?PHP
/*
instantiate the class
*/
include('csvdict.class.php');
$dict = new csvDict;

/*
process the csv file
we are using the file name for the table name
we could provide our own table name...
$dict->processCSV('sample.csv','myTable');
*/
$dict->processCSV('sample.csv');

/*
inform class of the primary column
we are using the first field in the csv file as the primary column
we could also name it, if the name is known...
$dict->setPrimColumn('id');
*/
$dict->setPrimColumn(0);

/*
inform class that primary column is auto incremented
*/
$dict->isAuto = true;

/*
displaying data dictionary
*/
$display = $dict->getDisplay();
echo
$display.'<hr>';

/*
displaying create table query
*/
$query = $dict->getTableQuery();
echo
$query.'<hr>';

/*
displaying row insert queries
the dataRows property will not be available if the includeData property is false
*/
foreach( $dict->dataRows[0] as $key=>$data ){
   
$query = $dict->getInsertQuery($key);
    echo
$query.'<br>';
}

?>