PHP Classes
elePHPant
Icontem

File: ibclass_tester.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Henrik Schmidt  >  IB Class  >  ibclass_tester.php  >  Download  
File: ibclass_tester.php
Role: Example script
Content type: text/plain
Description: A simple demoapplication
Class: IB Class
Connect to Interbase and get blobs transparently
Author: By
Last change: bugfix
Date: 12 years ago
Size: 2,858 bytes
 

Contents

Class file image Download
<html>
  <head>
    <title>InterBase ISQL</title>
  </head>
  <BODY bgcolor="#ffffff" text="black"><font face="arial,verdana,helvetica" size=3>

<?
 
require_once("ibclass.php");
 
//$qrystring = "SELECT u.a ttt, w.* FROM test3 w, test2 y, test u, test";
  //$qrystring = "SELECT * FROM test3, test2, test";
  //$qrystring = "select A, B, BLUBB from test left join test3 on val=(a-1)";
 
$qrystring = "select * from test3 order by val ";

 
$ibc = new TIBConnection("127.0.0.1:e:\\db\\test.gdb","sysdba","masterkey");

  if ( !
$ibc->IsOpen() )
     echo
"Can't connect to database, sorry.";
  else
  {
   
$ibq2 = new TIBQuery( $ibc);
   
$ibq2->Execute( "insert into test values (3,'hejja')" );

   
$ibq2->Execute( "insert into test3 values ( ?, ? )",
                     array(
22, $ibq2->BlobFromString("oj va gott det kan vara med glass ibland!") ) );

   
$test = $ibq2->BlobFromFile("intext.txt");

   
$ibq2->Execute( "insert into test3 values (32,?)", array( $test ) );

   
$ibq2->Execute( "insert into test3 values (32,?)", array( NULL ) );
   
    echo
"<br>";
   
   
var_dump($ibc->GEN_ID("testgenerator2"));
   
    echo
"<br>";


    unset(
$ibq2);

   
$ibq = new TIBQuery( $ibc, $qrystring );

    if ( !
$ibq->Open() )
      echo
"<br><font color=#AA0000>Can't run the query</font>";
    else
    {
      for (
$i=0; $i < $ibq->FldCount; $i++)
      {
        echo
"<table cellspacing='1' cellpadding='3' border='1' align=left>";
        echo
"<tr bgcolor='#AAAAFF'><td colspan=2>Field: #$i</td></tr>";

        echo
"<tr><td>Name</td><td>".$ibq->FldRealName($i)."</td></tr>";
        echo
"<tr><td>Alias</td><td>".$ibq->FldAlias($i)."</td></tr>";
        echo
"<tr><td>Table</td><td>".$ibq->FldTable($i)."</td></tr>";
        echo
"<tr><td>Length</td><td>".$ibq->FldLength($i)."</td></tr>";
        echo
"<tr><td>Type</td><td>".$ibq->FldType($i)."</td></tr>";

        echo
"</table>";
      }

      echo
"<br clear=all><table cellspacing='1' cellpadding='3' border='1'><tr bgcolor=#bed2e6>";

      for (
$i=0; $i < $ibq->FldCount; $i++)
        echo
"<td>".$ibq->FldAlias($i)."</td>";

      echo
"<td>BLUPP extra</td>";
      echo
"</tr>";

      while (
$ibq->Next() )
      {
        echo
"<tr>";

          for (
$i=0; $i<$ibq->FldCount; $i++)
          {
            echo
"<td>" ;
            if(
$ibq->FldIsEmpty($i) )
              echo
"&lt;empty&gt;";
            else
              echo
htmlentities( $ibq->Fld($i) );
           
            echo
"</td>";
          }
          echo
"<td>" . $ibq->Fld("blubb") . "</td>";
          echo
"<td>" . $ibq->FldGetTextLength( "blubb" ) . "</td>";

        echo
"</tr>";
      }
      echo
"</table>";

     
$ibq->Close();
    }
   
$ibc->Close();
  }
?>
</body>
</html>