This package is abandoned and no longer maintained. No replacement package was suggested.

PHP singleton for PDO

1.1.0 2015-09-28 12:40 UTC

This package is not auto-updated.

Last update: 2021-10-02 02:33:37 UTC


README

PHP singleton for PDO

Latest Stable Version License

Requirements

  • PHP >= 5.3
  • PHP PDO extension

Installation

Install directly via Composer:

$ composer require starter-kit/sql

Basic Usage

<?php

// Require your autoloading script (Composer autoload here) to use namespaces
require_once 'vendor/autoload.php';

use StarterKit\SQL\SimplePDO;

// First instanciation : pass your DB parameters
$PDOInstance = SimplePDO::getInstance('YOUR_DB_NAME', 'YOUR_DB_SERVER', 'YOUR_DB_PORT', 'YOUR_DB_USER', 'YOUR_DB_PASSWORD');

// Later in your code : you can retrieve your instance at any time, without creating new PDO connection
$query = SimplePDO::getInstance()->prepare('SELECT * FROM YOUR_DB_TABLE');
$res = $query->execute();