Login   Register  
PHP Classes
elePHPant
Icontem

File: test_clone.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Erwin Kooi  >  PHPXBase  >  test_clone.php  >  Download  
File: test_clone.php
Role: Example script
Content type: text/plain
Description: test clone function
Class: PHPXBase
Access dbf/foxpro files without PHP ext.
Author: By
Last change:
Date: 2006-01-22 04:35
Size: 1,394 bytes
 

Contents

Class file image Download
<?
/**
* ----------------------------------------------------------------
*            XBase
*            test_clone.php    

*  Developer        : Erwin Kooi
*  released at      : Jan 2006
*  last modified by : Erwin Kooi
*  date modified    : Jan 2006
*                                                               
*  Info? Mail to info@cyane.nl

* --------------------------------------------------------------
*
* Demonstration how to clone table meta-data to another and copy records
*
**/

    /* load the required classes */
    
require_once "Column.class.php";
    require_once 
"Record.class.php";
    require_once 
"Table.class.php";
    require_once 
"WritableTable.class.php";
    
    
/* open a template table object and read it */
    
$tableParent = new XBaseTable("test/bond.DBF");
    
$tableParent->open();
    
    
/* create a new table */
    
$tableNew XBaseWritableTable::cloneFrom($tableParent);
    
$tableNew->openWrite("test/created.dbf",true);
    while (
$record=$tableParent->nextRecord()) {
        
$tableNew->appendRecord();
        
$tableNew->record->copyFrom($record);
        
$tableNew->writeRecord();
    }
    
$tableNew->close();
    
$tableParent->close();
    
    
/* open created file*/
    
$table = new XBaseTable("test/created.dbf");
    
$table->open();

    
/* xml output */
    
echo "<pre>\n";
    echo 
htmlspecialchars($table->toXML());
    echo 
"</pre>\n";

    
/* close the table */
    
$table->close();
?>