<?
 
    require("metafire.lib.php");
 
    $fbird = new metafire;
 
    // test simple query
 
    // use this if only select operation
 
    
 
    $sql = "select first_name,last_name  from employee";
 
    $intQuery=$fbird->Query($sql,0,1);
 
    $rows=0;
 
    while ($fbird->fetchObject($intQuery)) {
 
        $rows++;
 
        echo $rows.". ".$fbird->fetchRow("first_name")." ".$fbird->fetchRow("last_name")."<br>";
 
    }
 
    echo "Query script: ".$fbird->strQuery."<br><br><br>";
 
    $freeResult=$fbird->FreeQueryResult($intQuery);
 
    
 
    
 
    /*
 
    $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>"; 
 
        }
 
          $freeResult=$fbird->FreeQueryResult($intQuery);
 
    */
 
    
 
    
 
    /*
 
    // 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";
 
    //$fbird->Query($sql,1,1);
 
    
 
    //not auto commit
 
    $intQuery=$fbird->Query($sql,1,0);
 
    //$fbird->CommitTransaction($intQuery);
 
    
 
    //u can only rollback what u have no committed
 
    $fbird->RollbackTransaction($intQuery);
 
    */
 
    
 
    
 
        
 
    // test prepared query 'update' with transaction, commit and rollback
 
    $updates = array(
 
        'Australia' => 'Dollar',
 
        'Belgium' => 'Franc'
 
        );
 
    
 
    /*    
 
    $sql ="UPDATE country set currency= ? where country = ?";
 
    
 
    //using transaction
 
    //$intPreQuery=$fbird->PreQuery($sql,1);
 
    
 
    //default, without transaction 
 
       $intPreQuery=$fbird->PreQuery($sql);
 
 
        while (list($id, $name) = each($updates)) {
 
                    $intQuery=ibase_execute($intPreQuery, $name, $id);
 
        }
 
       $fbird->FreePreQuery($intPreQuery);
 
       
 
       // always commit if using transaction
 
       //$aryResult=$fbird->CommitTransaction($intPreQuery);
 
       
 
    // transaction could be more powerful in sql script running in database backend engine 
 
    */
 
    
 
    
 
        echo "Done!";
 
    
 
    
 
    
 
    
 
?>
 
 |