A super easy PHP Framework for web development!
https://github.com/exacti/phacil-framework
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.1 KiB
92 lines
2.1 KiB
6 years ago
|
<?php
|
||
3 years ago
|
/*
|
||
|
* Copyright © 2021 ExacTI Technology Solutions. All rights reserved.
|
||
|
* GPLv3 General License.
|
||
|
* https://exacti.com.br
|
||
|
* Phacil PHP Framework - https://github.com/exacti/phacil-framework
|
||
|
*/
|
||
6 years ago
|
|
||
3 years ago
|
namespace Phacil\Framework\Databases;
|
||
|
|
||
|
use Exception;
|
||
|
use stdClass;
|
||
|
|
||
|
/**
|
||
|
* Oracle driver connector
|
||
|
*
|
||
|
* @package Phacil\Framework\Databases
|
||
|
*/
|
||
6 years ago
|
final class Oracle{
|
||
3 years ago
|
/**
|
||
|
*
|
||
|
* @var resource|false
|
||
|
*/
|
||
6 years ago
|
private $connection;
|
||
3 years ago
|
|
||
|
|
||
|
/**
|
||
|
* @param string $hostname
|
||
|
* @param string $username
|
||
|
* @param string $password
|
||
|
* @param string $database
|
||
|
* @param string $port
|
||
|
* @param string $charset
|
||
|
* @return void
|
||
|
* @throws Exception
|
||
|
*/
|
||
6 years ago
|
public function __construct($hostname, $username, $password, $database, $port = '1521', $charset = 'utf8') {
|
||
|
$this->connection = oci_connect($username, $password, $hostname."/".$database, $charset);
|
||
|
if (!$this->connection) {
|
||
|
$e = oci_error();
|
||
|
$this->error = $e;
|
||
|
throw new \Exception(trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR));
|
||
|
}
|
||
|
oci_set_client_info($this->connection, "Administrator");
|
||
3 years ago
|
//oci_set_module_name($this->connection, $module);
|
||
|
//oci_set_client_identifier($this->connection, $cid);
|
||
6 years ago
|
|
||
|
}
|
||
3 years ago
|
|
||
|
/**
|
||
|
* @param string $sql
|
||
|
* @return stdClass
|
||
|
* @throws Exception
|
||
|
*/
|
||
6 years ago
|
public function query($sql) {
|
||
|
$stid = oci_parse($this->connection, $sql);
|
||
|
oci_execute($stid);
|
||
|
if (!$this->connection) {
|
||
|
oci_fetch_all($stid, $res);
|
||
|
|
||
|
$result = new \stdClass();
|
||
|
$result->num_rows = oci_num_rows($stid);
|
||
|
$result->row = isset($res[0]) ? $res[0] : array();
|
||
|
$result->rows = $res;
|
||
|
|
||
|
return $result;
|
||
|
|
||
|
|
||
|
} else {
|
||
|
throw new \Exception('Error: ' . oci_error() . '<br />' . $sql);
|
||
|
}
|
||
|
}
|
||
3 years ago
|
|
||
6 years ago
|
public function escape($value) {
|
||
|
return str_replace("'", "", $value);
|
||
|
}
|
||
|
|
||
|
public function countAffected() {
|
||
|
return NULL;
|
||
|
}
|
||
|
public function getLastId() {
|
||
|
return NULL;
|
||
|
}
|
||
|
|
||
|
public function isConnected() {
|
||
|
return $this->connection;
|
||
|
}
|
||
|
|
||
|
public function __destruct() {
|
||
|
oci_close($this->connection);
|
||
|
}
|
||
|
}
|