2017 © Pedro Peláez
 

library slimmer-pdo

PDO database library for Slim Framework

image

nicolask/slimmer-pdo

PDO database library for Slim Framework

  • Tuesday, June 26, 2018
  • by nicolask
  • Repository
  • 1 Watchers
  • 1 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 80 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Slimmer-PDO

Slimmer-PDO is a fork of the original FaaPz/Slim-PDO prepared to be used in PHP >=7.1., (*1)

PDO database library for Slim Framework, (*2)

Installation

Use Composer, (*3)

"require": {
    "nicolask/slimmer-pdo": "~1.10"
}

Usage

Examples selecting, inserting, updating and deleting data from or into users table., (*4)

require_once 'vendor/autoload.php';

$dsn = 'mysql:host=your_db_host;dbname=your_db_name;charset=utf8';
$usr = 'your_db_username';
$pwd = 'your_db_password';

$pdo = new \Slim\PDO\Database($dsn, $usr, $pwd);

// SELECT * FROM users WHERE id = ?
$selectStatement = $pdo->select()
                       ->from('users')
                       ->where('id', '=', 1234);

$stmt = $selectStatement->execute();
$data = $stmt->fetch();

// INSERT INTO users ( id , usr , pwd ) VALUES ( ? , ? , ? )
$insertStatement = $pdo->insert(array('id', 'usr', 'pwd'))
                       ->into('users')
                       ->values(array(1234, 'your_username', 'your_password'));

$insertId = $insertStatement->execute(false);

// UPDATE users SET pwd = ? WHERE id = ?
$updateStatement = $pdo->update(array('pwd' => 'your_new_password'))
                       ->table('users')
                       ->where('id', '=', 1234);

$affectedRows = $updateStatement->execute();

// DELETE FROM users WHERE id = ?
$deleteStatement = $pdo->delete()
                       ->from('users')
                       ->where('id', '=', 1234);

$affectedRows = $deleteStatement->execute();

The sqlsrv extension will fail to connect when using error mode PDO::ERRMODE_EXCEPTION (default). To connect, you will need to explicitly pass array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING) (or PDO::ERRMODE_SILENT) into the constructor, or override the getDefaultOptions() method when using sqlsrv., (*5)

Documentation

See DOCUMENTATION, (*6)

Changelog

See CHANGELOG, (*7)

License

See LICENSE, (*8)

The Versions

26/06 2018

dev-master

9999999-dev https://github.com/nicolask/Slim-PDO

PDO database library for Slim Framework

  Sources   Download

MIT

The Requires

  • php ^7.1
  • ext-pdo *

 

The Development Requires

by Nicolas Krueger

database framework pdo slim

26/06 2018

1.11.0

1.11.0.0 https://github.com/nicolask/Slim-PDO

PDO database library for Slim Framework

  Sources   Download

MIT

The Requires

  • php ^7.1
  • ext-pdo *

 

The Development Requires

by Nicolas Krueger

database framework pdo slim

21/03 2018

dev-v2-dev

dev-v2-dev https://github.com/FaaPz/Slim-PDO

PDO database library for Slim Framework

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-pdo *

 

The Development Requires

database framework pdo slim