Login   Register  
PHP Classes
elePHPant
Icontem

File: ___case_of_use.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Michal Palma  >  CSV to SQL database converter  >  ___case_of_use.php  >  Download  
File: ___case_of_use.php
Role: Example script
Content type: text/plain
Description: Case of use
Class: CSV to SQL database converter
Import data from a CSV file into a database
Author: By
Last change:
Date: 9 years ago
Size: 955 bytes
 

Contents

Class file image Download
<?php
/*
* Some cases of use
* @package Csv2Db
* @date 2005-08-08
*/

require("_preload.php");

try {
    
$Csv2Db = new Csv2Db("test.csv"$separator ";"$charset "cp1250"$useconfig true);
    echo 
"Processing...<br/>";
    
flush();
    
$Csv2Db->dbWrite();
}
catch (
Exception $e) {
    echo 
"<hr />";
    echo 
"Exception code:  <font style='color:blue'>"$e->getCode() ."</font>";
    echo 
"<br />";
    echo 
"Exception message: <font style='color:blue'>"nl2br($e->getMessage()) ."</font>";
    echo 
"<br />";
    echo 
"Thrown by: '"$e->getFile() ."'";
    echo 
"<br />";
    echo 
"on line: '"$e->getLine() ."'.";
    echo 
"<br />";
    echo 
"<br />";
    echo 
"Stack trace:";
    echo 
"<br />";
    echo 
nl2br($e->getTraceAsString());
    echo 
"<hr />";

    exit;
}
echo 
"CSV file was Succesfully transfered to database table.<br />";
echo 
"Record has "$Csv2Db->getRowsCount() ." rows.<br />";

?>