PHP Classes

File: test_metafire.php

Recommend this page to a friend!
  Classes of meta   metafire   test_metafire.php   Download  
File: test_metafire.php
Role: Example script
Content type: text/plain
Description: example file
Class: metafire
database abstraction layer for firebird/interbase
Author: By
Last change: modify some functional test
Date: 20 years ago
Size: 2,184 bytes


Class file image Download
$fbird = new metafire;
// test simple query
    // use this if only select operation
$sql = "select first_name,last_name from employee";
    while (
$fbird->fetchObject($intQuery)) {
$rows.". ".$fbird->fetchRow("first_name")." ".$fbird->fetchRow("last_name")."<br>";
"Query script: ".$fbird->strQuery."<br><br><br>";
    $coln = $fbird->GetNumFields($intQuery);
    for ($i=0 ; $i < $coln ; $i++) {
          $col_info = $fbird->GetFieldInfo($intQuery,$i);
             echo "name: ".$col_info['name']."\n";
            echo "alias: ".$col_info['alias']."\n";
             echo "relation: ".$col_info['relation']."\n";
            echo "length: ".$col_info['length']."\n";
            echo "type: ".$col_info['type']."<br>";
    // test query with transaction
    // prefereble for insert,update,delete operation as u can rollback when u need to
    $sql = "update employee set last_name='Nelson' where emp_no=2";
    //not auto commit
    //u can only rollback what u have no committed
    // test prepared query 'update' with transaction, commit and rollback
$updates = array(
'Australia' => 'Dollar',
'Belgium' => 'Franc'
    $sql ="UPDATE country set currency= ? where country = ?";
    //using transaction
    //default, without transaction

        while (list($id, $name) = each($updates)) {
                    $intQuery=ibase_execute($intPreQuery, $name, $id);
       // always commit if using transaction
    // transaction could be more powerful in sql script running in database backend engine
echo "Done!";