User Tools

Site Tools


kurs:hrdb.php
<?php
abstract class HRDB {  //abstract only as a demonstration
 
  function connect() {
  global $db;
  if (!$db = @oci_pconnect('hr', 'hr', 'orcl11')) {
    print "<pre>";
    print_r(oci_error());
    print "</pre>";
	exit;
    }
  }
  
  function db_select($sql, $bp) {
  global $db;
    
	if (!$db) {$this->connect();}
	
    $q = oci_parse($db, $sql);
    foreach ($bp as $param => $value) {
	  oci_bind_by_name($q, $param, $value, 32 );
	}
    
	$r = oci_execute($q, OCI_DEFAULT);
    $rows = oci_fetch_array($q, OCI_ASSOC);
	return $rows;
  }

 function db_insert($sql, $bp) {
  global $db;
    
	if (!$db) {$this->connect();}
		
    $q = oci_parse($db, $sql);
    foreach ($bp as $param => $value) {
	  oci_bind_by_name($q, "p_$param", $value, 32 );
	}
    oci_bind_by_name($q, ":ret_id",   $rowid, 32);	
	$r = oci_execute($q, OCI_DEFAULT);	
	
	return $rowid;
  }
	
  
  function dump() {    
    print_r($this);
  }	

}

?> 
kurs/hrdb.php.txt · Last modified: 2014/09/10 21:22 (external edit)