Giter Club home page Giter Club logo

php-database's Introduction

php-database

This library provides utilities function to ease MySql databse connections

composer require hugsbrugs/php-database

Create a config.ini file

[mysql database]
MYSQL_DB_HOST = 'localhost'
MYSQL_DB_PORT = 3306
MYSQL_DB_USER = 'username'
MYSQL_DB_PASS = 'password'
MYSQL_DB_NAME = 'database_name'
MYSQL_DB_ENV = 'dev';'prod'

[sqllite database]
SQLLITE_DB_PATH = '/PATH_TO/sqllite'
SQLLITE_DB_USER = ''
SQLLITE_DB_PASS = ''
SQLLITE_DB_NAME = 'garden'
SQLLITE_DB_ENV = 'dev';'prod'

Create a php file

require_once __DIR__ . '/config.php';
require_once __DIR__ . '/../vendor/autoload.php';

use Hug\Database\MySqlDB as MySqlDB;

# Use constants defined in config.ini to get default db
$db = MySqlDB::getInstance();
list_tables($db1);

# Or pass params
$db = MySqlDB::getInstance(
	$host = 'localhost', 
	$port = 3306, 
	$user = 'username', 
	$pass = 'password', 
	$name = 'database_name', 
	$env = 'dev'
);

Have a look at example folder for full working code.

Author

Hugo Maugey visit my website ;)

php-database's People

Contributors

hugsbrugs avatar

Watchers

James Cloos avatar  avatar

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.