Skip to content

Commit

Permalink
Merge pull request #19 from byjg/oracle
Browse files Browse the repository at this point in the history
Oracle OCI + Mutex Cache + Transaction
  • Loading branch information
byjg authored Jun 27, 2024
2 parents 705dea4 + 5e31e22 commit f720236
Show file tree
Hide file tree
Showing 21 changed files with 1,082 additions and 86 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
--health-interval=10s
--health-timeout=20s
--health-retries=10
postgres:
image: postgres
env:
Expand All @@ -44,6 +45,7 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
sqlserver:
image: mcr.microsoft.com/mssql/server
env:
Expand Down
7 changes: 5 additions & 2 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
tasks:
- name: Run Composer
command: |
composer install
init: |
sudo ln -s /etc/php/8.2/mods-available/sqlsrv.ini /etc/php/8.2/cli/conf.d/20-sqlsrv.ini
sudo ln -s /etc/php/8.2/mods-available/pdo_sqlsrv.ini /etc/php/8.2/cli/conf.d/30-pdo_sqlsrv.ini
sudo ln -s /etc/php/8.2/mods-available/oci8.ini /etc/php/8.2/cli/conf.d/20-oci8.ini
echo oci8.privileged_connect=1 | sudo tee -a /etc/php/8.2/mods-available/oci8.ini
command: |
composer install
docker compose -f docker-compose.yml up -d
image: byjg/gitpod-image:full
Expand Down
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ See below the current implemented drivers:
| Postgres | psql://username:password@hostname:port/database | getDbRelationalInstance() |
| Sql Server (DbLib) | dblib://username:password@hostname:port/database | getDbRelationalInstance() |
| Sql Server (Sqlsrv) | sqlsrv://username:password@hostname:port/database | getDbRelationalInstance() |
| Oracle (OCI) | oci://username:password@hostname:port/database | getDbRelationalInstance() |
| Oracle (OCI8) | oci8://username:password@hostname:port/database | getDbRelationalInstance() |
| Generic PDO | pdo://username:password@pdo_driver?PDO_PARAMETERS | getDbRelationalInstance() |

Expand All @@ -42,19 +41,23 @@ $conn = \ByJG\AnyDataset\Db\Factory::getDbRelationalInstance("mysql://root:passw

## Examples

- [Basic Query and Update](basic-query.md)
- [Cache results](cache.md)
- [Database Transaction](transaction.md)
- [Load Balance and Connection Pooling](load-balance.md)
- [Database Helper](helper.md)
- [Basic Query and Update](docs/basic-query.md)
- [Cache results](docs/cache.md)
- [Database Transaction](docs/transaction.md)
- [Load Balance and Connection Pooling](docs/load-balance.md)
- [Database Helper](docs/helper.md)

## Advanced Topics

- [Passing Parameters to PDODriver](parameters.md)
- [MySQL SSL Connection](mysql-ssl.md)
- [FreeTDS/Dblib Date Issue](freetds.md)
- [Generic PDO Driver](generic-pdo-driver.md)
- [Running Tests](tests.md)
- [Passing Parameters to PDODriver](docs/parameters.md)
- [Generic PDO Driver](docs/generic-pdo-driver.md)
- [Running Tests](docs/tests.md)

## Database Specifics

- [MySQL](docs/mysql.md)
- [Oracle](docs/oracle.md)
- [SQLServer](docs/sqlserver.md)


## Install
Expand Down
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,19 @@ services:
timeout: 20s
interval: 10s
retries: 10

oracle:
container_name: oracle
image: container-registry.oracle.com/database/express:21.3.0-xe
environment:
- ORACLE_PWD=password
ports:
- "1521:1521"
volumes:
- ./testsdb/assets:/opt/oracle/scripts/startup

# healthcheck:
# test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
# timeout: 20s
# interval: 10s
# retries: 10
6 changes: 0 additions & 6 deletions docs/freetds.md

This file was deleted.

6 changes: 5 additions & 1 deletion docs/mysql-ssl.md → docs/mysql.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Connecting To MySQL via SSL
# Driver: MySQL

The connection string can have special attributes to connect using SSL.

## Connecting To MySQL via SSL

Read [here](https://gist.github.com/byjg/860065a828150caf29c20209ecbd5692) about create SSL mysql

Expand Down
27 changes: 27 additions & 0 deletions docs/oracle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Driver: Oracle

The Oracle Driver don't use the PHP PDO Driver. Instead, uses the OCI library.

The Oracle Connection String has the following format:


```text
oci8://user:pass@server:port/serviceName?parameters
```

The `parameters` can be:

* `codepage`=UTF8
* `conntype`=default|persistent|new
* `session_mode`=OCI_DEFAULT|OCI_SYSDBA|OCI_SYSOPER

## conntype

* If conntype = default will call the `oci_connect()` command;
* If conntype = new will call the `oci_new_connect()` command;
* If conntype = persistent will call the `oci_pconnect()` command;

## session_mode

The `OCI_DEFAULT`, `OCI_SYSDBA` AND `OCI_SYSOPER` are the PHP Constants
and they are `0`, `2` and `4` respectively;
14 changes: 14 additions & 0 deletions docs/sqlserver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Driver: Microsoft SQL Server

The SQLServer can be connected using both FreeDTS / Dblib (Sybase) or SQLSVR driver.

They have specifics, but both are able to connect to SQLServer.

There are some specifics as you can see below.

## The Date format Issues

Date has the format `"Jul 27 2016 22:00:00.860"`. The solution is:

Follow the solution:
[https://stackoverflow.com/questions/38615458/freetds-dateformat-issues](https://stackoverflow.com/questions/38615458/freetds-dateformat-issues)
Loading

0 comments on commit f720236

Please sign in to comment.