HRDB.php

employees.php

<?php 

require('DB-Classes/Employee.php');

$employee = new Employee(100);

//$employee->connect();

$employee->read();

print $employee->last_name ."\n";

$employee->dump();

$new_employee = new Employee(0);

$new_employee->first_name = 'Mark';
$new_employee->last_name  = 'Hofstetter';
$new_employee->email      = 'jo@eh';
$new_employee->job_id     = 'IT_PROG';

$new_employee->store();

$new_employee->dump();

?>             

Employee.php

<?php
require('HRDB.php');
class Employee extends HRDB {  
  
  function Employee($employee_id) {    
    i$this->employee_id = $employee_id;		
  }
  
  function read() {    
    $sql = "select * from employees where employee_id = :employee_id";
    $rows = $this->db_select( $sql, 
	     array('employee_id' => $this->employee_id,) );
		
	foreach ($rows as $key => $value) {
      $key = strtolower($key);
	  $this->{$key} = $value;
	}
	// print_r($rows);
  }
  
  function store() {
    $sql = "insert into employees (
 EMPLOYEE_ID,
 FIRST_NAME,
 LAST_NAME,
 EMAIL,
 HIRE_DATE,
 JOB_ID) 
values
 (employees_seq.nextval,
 :p_first_name,
 :p_last_name,
 :p_email,
 sysdate,
 :p_job_id
) returning employee_id into :ret_id";
    $this->employee_id = 
	     $this->db_insert( $sql, array(
		 'first_name' => $this->first_name,
         'last_name'  => $this->last_name,
         'email'      => $this->email,
         'job_id'     => $this->job_id,
		 )
		 );  
                                                
  }                                             
                                                
  function find_by_id($id) {                    
                                                
  }                                             
                                                
} // end class Employee                         
?>