geofox

Conexion OCI PHP

Apr 23rd, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. <?php
  2. define ("USUARIO","own_tester");  //USUARIO DE LA BASE DE DATOS
  3. define ("PASSWORD","123"); // CONTRASEÑA DE LA BASE DE DATOS
  4. define ("HOST_INSTANCIA","localhost/orcl"); //HOST E INSTANCIA DEL SERVIDOR LOCALHOST/INSTANCIA
  5. define ("CHARACTER_SET","AL32UTF8");
  6.  
  7. class Conexion{
  8. private $conexion;
  9.  
  10. public function __construct(){ //Constructor
  11.     $this->conexion = oci_connect(USUARIO, PASSWORD, HOST_INSTANCIA,CHARACTER_SET);
  12.     if(!$this->conexion){
  13.         echo "ERROR!!! AL CONECTAR AL SERVIDOR DE BASE DE DATOS";
  14.     }
  15.    $this->alter_sesion_date();
  16.  
  17. }
  18. public function __destruct(){ //Destructor
  19. oci_close($this->conexion);
  20.  
  21. }
  22.  
  23. public function query($sql){
  24.  return oci_parse($this->conexion,$sql);
  25.  
  26. }
  27. public function ejecutar($stm){
  28.     return oci_execute($stm);
  29.    
  30.  
  31. }
  32. public function alter_sesion_date(){
  33. $sesion = $this->query("alter session set nls_date_format='DD/MM/YYYY HH24:MI:SS'");
  34. $this->ejecutar($sesion);
  35.  
  36. }
  37.  
  38.  
  39.  
  40. }
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment