PHP Classes

PHP Light DbaseToSql: Import Dbase files and generate MySQL dump files

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 154 All time: 9,040 This week: 55Up
Version License PHP version Categories
pldts 1.0.1Custom (specified...5PHP 5, Databases, Files and Folders
Description 

Author

This package can import Dbase files and generate MySQL dump files.

It can take a given database file in XBase format and reads its records.

The package can generate text with SQL statements into a file that can be imported by MySQL to regenerate the same database in MySQL tables.

Picture of zinsou A.A.E.Moïse
  Performance   Level  
Name: zinsou A.A.E.Moïse is available for providing paid consulting. Contact zinsou A.A.E.Moïse .
Classes: 50 packages by
Country: Benin Benin
Age: 34
All time rank: 6761 in Benin Benin
Week rank: 215 Up1 in Benin Benin Equal
Innovation award
Innovation award
Nominee: 23x

Winner: 2x

Recommendations

Recommendation for a PHP class to convert dbf to mysql
Access old DBF dBase III files data to convert in mySql

Upload code source as zip file
I can't figure out how to upload a zip file.

Example

<?php
$dbf
='83750a1c0300000081001f0000000000000000000000000000000000000000004e414d450000000000000043000000000a00000000000000000000000000000046495253544e414d45000043000000000a000000000000000000000000000000434f4d4d454e54000000004d000000000a0000000000000000000000000000000d207a696e736f75202020206973616163202020202030303030303030310020207a696e736f75202020204d6f69736520202020203030303030303032002020676e696d61766f202020636f726e656c6965202030303030303030330020';
$dbt='0400000000000000000000000000000003000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffff08000400000066696c730000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000025010024c27f0700c4004c0100bf5201000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffff080004000000706572650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000025010024c27f0700c4004c0100bf5201000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffff0800040000006d6572650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000025010024c27f0700c4004c0100bf5201000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';

$x=hex2bin($dbf);// $x=pack('H*',$dbf);
$y=hex2bin($dbt);// $y=pack('H*',$dbt);
// var_dump($x,$y);

file_put_contents('fortrue.dbf',$x);
file_put_contents('fortrue.dbt',$y);
require(
'dbasetosql.class.php');
echo
'<pre>';
$x=new dbasetosql('fortrue.dbf');//create from fortrue.dbf to fortrue.sql
// $x=new dbasetosql('fortrue.dbf','newfortrue');//create from fortrue.dbf to the database newfortrue.sql

echo '<div style="background-color:green">'.$x->ToSQL().'</div>';//generate sql code
$x->save_tofile();//save it to fortrue.sql in your directory but you can call directly method::save without method::toSQL with the same parameter as toSQL
echo'<hr/>';

echo
'<div style="background-color:#00bcd4">'.$x->ToSQL(true,'newtable').'</div>';;//generate sql code with a database name specified in the constructor and the table name newtable
echo'<hr>';
echo
'<div style="background-color:gray">'. $x->ToSQL(false,'mytable').'</div>';;//generate sql code without creating a database but only the table with the name mytable
echo'<hr/>';
echo
'</pre>';


Details

PHP Light DbaseToSql is a tiny package to import Xbase with/without memo files to basic SQL syntax... for a how to use example run the file BuildDbaseAndTest.php in your browser no need of DBF file to test it for the first time...Then you can look into the package folder.You must see three files: one .dbf ,one .dbt and one another with the .sql extension... It is a very light package ,so Feel to make feedback for improvement at leizmo@gmail.com or use the forum to do it.... ps: the PECL dbase extension is not required...

  Files folder image Files (5)  
File Role Description
Accessible without login Plain text file BuildDbaseAndTest.php Example example script
Plain text file dbasetosql.class.php Class class source
Accessible without login Plain text file license.txt Lic. license file
Plain text file ReadDbase.classes.php Class class source
Accessible without login Plain text file readme.txt Doc. readme

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:154
This week:0
All time:9,040
This week:55Up