Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Pablo DallOglio  >  SQL2TXT  >  example.php  >  Download  
File: example.php
Role: ???
Content type: text/plain
Description: example file
Class: SQL2TXT
Author: By
Last change:
Date: 2001-05-10 20:43
Size: 989 bytes
 

Contents

Class file image Download
<html>
<? require("sql2txt.php"); ?>

<?

// this is an array with column lenghts-alignment of TXT file
$myarray = array("10-left", "40-left", "20-left", "20-right");

// SQL instruction that will select data to write into TXT file
$sql = "select id, name, phone, income from customer where income>10000";

$header = "HEADER OF TXT FILE";  // HEADER
$trailer = "TRAILER OF TXT FILE";  // FOOTER

// the class is inhearited
$conversao = new sql2txt;

// 1 - DBase name
// 2 - port
// 3 - DbUser
// 4 - PassWord
$ok = $conversao->openSQL("dbname", "5432", "username", "password");
echo($ok);

// Open the SQL file for write
$ok = $conversao->opentxt("destination.txt");
echo($ok);

// Get the Columns and write it into a SQL file
// 1 - SQL instructions
// 2 - array with lenghts/alignments
// 3 - header
// 4 - trailer
$conversao->InsertColumnsIntoTXT( $sql, $myarray, $header, $trailer );

// Close TXT and SQL files
$conversao->Closeall();
?>
</html>