| EMPNO | ENAME | JOB | MGR | HIREDATE | SAL | COMM | DEPTNO |
|---|
| 7369 | SMITH | CLERK | 7902 | 80-12-17 | 800 | | 20 |
| 7499 | ALLEN | SALESMAN | 7698 | 81-02-20 | 1600 | 300 | 30 |
| 7521 | WARD | SALESMAN | 7698 | 81-02-22 | 1250 | 500 | 30 |
| 7566 | JONES | MANAGER | 7839 | 81-04-02 | 2975 | | 20 |
| 7654 | MARTIN | SALESMAN | 7698 | 81-09-28 | 1250 | 1400 | 30 |
| 7698 | BLAKE | MANAGER | 7839 | 81-05-01 | 2850 | | 30 |
| 7782 | CLARK | MANAGER | 7839 | 81-06-09 | 2450 | | 10 |
| 7788 | SCOTT | ANALYST | 7566 | 82-12-09 | 3000 | | 20 |
| 7839 | KING | PRESIDENT | | 81-11-17 | 5000 | | 10 |
| 7844 | TURNER | SALESMAN | 7698 | 81-09-08 | 1500 | 0 | 30 |
| 7876 | ADAMS | CLERK | 7788 | 83-01-12 | 1100 | | 20 |
| 7900 | JAMES | CLERK | 7698 | 81-12-03 | 950 | | 30 |
| 7902 | FORD | ANALYST | 7566 | 81-12-03 | 3000 | | 20 |
| 7934 | MILLER | CLERK | 7782 | 82-01-23 | 1300 | | 10 |
| 93 | 下岡秀幸 | ソフト | | | | | |
<?php
require_once("jp/ne/hi_ho/pat/dimension/Abstract.phl");
?>
<?php
class Director
{
var $builder_;
/**
* リソースを開く
*/
function Director($builder)
{
$this->builder_ = $builder;
}
/**
* データを作成し、返す
*/
function construct()
{
$this->builder_->open();
$this->builder_->get();
$this->builder_->make();
$this->builder_->close();
return $this->builder_->getResult();
}
}
class Builder
{
/**
* リソースを開く
*/
function open() { Abstract::set("open"); }
/**
* データを取得する
*/
function get() { Abstract::set("get"); }
/**
* 結果を作成する
*/
function make() { Abstract::set("make"); }
/**
* リソースを閉じる
*/
function close() { Abstract::set("close"); }
/**
* 結果を返す
*/
function getResult() { Abstract::set("getResult"); }
}
/**
* DBデータの表示
*/
class DbBuilder extends Builder
{
// 結果文字列を格納するバッファ
var $buf_;
var $conn_;
var $stmt_;
var $data_;
var $rows_;
function open()
{
$this->conn_ = OCILogon("scott", "tiger", "orcl");
$this->buf_ = "";
}
function get()
{
$this->stmt_ = OCIParse($this->conn_, "SELECT * FROM emp");
OCIExecute($this->stmt_);
$this->rows_ = OCIFetchStatement($this->stmt_, $this->data_);
}
function make()
{
$this->buf_ .= "<table border=\"1\">";
$this->buf_ .= "<tr>";
while (list( $key, $val ) = each( $this->data_ ) ) {
$this->buf_ .= "<th>$key</th>";
}
$this->buf_ .= "</tr>";
for ( $i = 0; $i < $this->rows_; $i++ ) {
reset($this->data_);
$this->buf_ .= "<tr>";
while ( $column = each($this->data_) ) {
$data = $column['value'];
$this->buf_ .= "<td>$data[$i]</td>";
}
$this->buf_ .= "</tr>";
}
$this->buf_ .= "</table>";
}
function close()
{
OCIFreeStatement($this->stmt_);
OCILogOff($this->conn_);
}
function getResult() { return $this->buf_; }
}
/**
* ファイルデータの表示
*/
class FileBuilder extends Builder
{
var $fp_;
var $buf_;
function open()
{
$this->fp_ = fopen(__FILE__, "r");
$this->buf_ = "";
}
function get()
{
while (!feof($this->fp_)) {
$this->buf_ .= fgets($this->fp_, 4096);
}
}
function make()
{
$this->buf_ = highlight_string($this->buf_);
}
function close()
{
fclose($this->fp_);
}
function getResult() { return $this->buf_; }
}
?>
<?php
/**
* main
*/
$arr = array(new DbBuilder(), new FileBuilder());
foreach ($arr as $index => $obj) {
$director = new Director($obj);
echo $director->construct();
echo "<hr>";
}
?>
1