PHP Classes

File: BuildDbaseAndTest.php

Recommend this page to a friend!
  Classes of zinsou A.A.E.Moïse   PHP Light DbaseToSql   BuildDbaseAndTest.php   Download  
File: BuildDbaseAndTest.php
Role: Example script
Content type: text/plain
Description: example script
Class: PHP Light DbaseToSql
Import Dbase files and generate MySQL dump files
Author: By
Last change:
Date: 6 years ago
Size: 5,637 bytes
 

Contents

Class file image Download
<?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>';