Giter VIP home page Giter VIP logo

php-anydataset-db's Introduction

AnyDataset-DB

Build Status Opensource ByJG GitHub source GitHub license GitHub release

Anydataset Database Relational abstraction. Anydataset is an agnostic data source abstraction layer in PHP.

See more about Anydataset here.

Features

  • Connection based on URI
  • Support and fix code tricks with several databases (MySQL, PostgresSql, MS SQL Server, etc)
  • Natively supports Query Cache by implementing a PSR-6 interface
  • Supports Connection Routes based on regular expression against the queries, that's mean a select in a table should be executed in a database and in another table should be executed in another (even if in different DB)

Connection Based on URI

The connection string for databases is based on URL.

See below the current implemented drivers:

Database Connection String Factory
Sqlite sqlite:///path/to/file getDbRelationalInstance()
MySql/MariaDb mysql://username:password@hostname:port/database getDbRelationalInstance()
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()
<?php
$conn = \ByJG\AnyDataset\Db\Factory::getDbRelationalInstance("mysql://root:[email protected]/myschema");

Examples

Advanced Topics

Install

Just type:

composer require "byjg/anydataset"

Dependencies

flowchart TD
    byjg/anydataset-db --> byjg/anydataset-array
    byjg/anydataset-db --> ext-pdo
    byjg/anydataset-db --> byjg/uri
    byjg/anydataset-db --> psr/cache
    byjg/anydataset-db --> psr/log

Open source ByJG

php-anydataset-db's People

Contributors

byjg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

php-anydataset-db's Issues

[Suggestion] Prepared statement

Hi,

I have suggestion about prepared statement: IMO, prepared statement object (PDOStatement) should be stored (in a "cache") and reused while the PDO instance is still the same.
Looking at method DbProDiver::getDBStatement, an SQL request is always prepared

https://github.com/byjg/anydataset-db/blob/3fffd5612f3991cf8eefc5f17e0062c2180d989d/src/DbPdoDriver.php#L110-L123

A really simple implementation might be like this.

$stmt = $this->cache->has($sql) ? $this->cache->get($sql) : $this->instance->prepare($sql);

Cache would be:

  • a "simple memory cache" (an associative array with SQL statement - as string - for key?);
  • destroyed everytime pdo instance change

What do you think about it?

Regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.