PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Marcus Vinicius R. Andrade   Access Data Object   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Code using all the files above.
Class: Access Data Object
Abstraction of the access to SQL based databases
Author: By
Last change:
Date: 20 years ago
Size: 2,267 bytes
 

Contents

Class file image Download
<?php
   
require_once('postgres.php');
   
$banco = new postgres;
   
$res = $banco->query("select nome from tb_categoria order by nome");
    while (
$linha = $banco->to_array($res)) {
        echo
$linha["nome"]."<br>";
    }
    echo
$banco->num_rows($res)."<br>";
    echo
$banco->num_fields($res)."<br>";
   

    echo
"<br>";
    echo
"Métodos da classe postgres.php";
    echo
"<br>";
   
$class_methods = get_class_methods(get_class($banco));
    foreach (
$class_methods as $method_name) {
        echo
"$method_name<br>";
    }

    echo
"<br>";
    echo
"<hr>";
    echo
"<br>";

    require_once(
'sqlserver.php');
   
$banco = new sqlserver;
   
$res = $banco->query("select Nome_Funcionario as nome,Guerra_Funcionario as guerra from Funcionario order by Guerra_Funcionario");
    while (
$linha = $banco->to_array($res)) {
        echo
$linha["guerra"] . "||" . $linha["nome"]."<br>";
    }
    echo
$banco->num_rows($res)."<br>";
    echo
$banco->num_fields($res)."<br>";
   
    echo
"<br>";
    echo
"Métodos da classe sqlserver.php";
    echo
"<br>";
   
$class_methods = get_class_methods(get_class($banco));
    foreach (
$class_methods as $method_name) {
        echo
"$method_name<br>";
    }

    echo
"<br>";
    echo
"<hr>";
    echo
"<br>";

    require_once(
'mysql.php');
   
$banco = new mysql;
   
$res = $banco->query("select dsc_modelo, cor_modelo from tb_modelos order by id_modelo");
    while (
$linha = $banco->to_array($res)) {
        echo
$linha["cor_modelo"] . " || " . $linha["dsc_modelo"]."<br>";
    }
    echo
$banco->num_rows($res)."<br>";
    echo
$banco->num_fields($res)."<br>";
   
    echo
"<br>";
    echo
"Métodos da classe mysql.php";
    echo
"<br>";
   
$class_methods = get_class_methods(get_class($banco));
    foreach (
$class_methods as $method_name) {
        echo
"$method_name<br>";
    }

    echo
"<br>";
    echo
"<hr>";
    echo
"<br>";
   
    require_once(
'odbc.php');
   
$banco = new odbc;
   
$res = $banco->query("select nome from tb_categoria order by nome");
    while (
$linha = $banco->to_array($res)) {
        echo
$linha["nome"]."<br>";
    }
    echo
$banco->num_rows($res)."<br>";
    echo
$banco->num_fields($res)."<br>";
    echo
"<br>";
    echo
"Métodos da classe odbc.php";
    echo
"<br>";
   
$class_methods = get_class_methods(get_class($banco));
    foreach (
$class_methods as $method_name) {
        echo
"$method_name<br>";
    }

?>