library database
A lightweight wrapper around PDO
leoshtika/database
A lightweight wrapper around PDO
- Saturday, February 27, 2016
- by leoshtika
- Repository
- 1 Watchers
- 1 Stars
- 61 Installations
- PHP
- 1 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 7 Versions
- 3 % Grown
A lightweight wrapper around PDO
, (*1)
Requirements
Installation with Composer
composer require leoshtika/database
- or updating your composer.json file
{
"require": {
"leoshtika/database": "~1.1"
}
}
Usage
Connect to an SQLite database
<?php
require_once 'vendor/autoload.php';
use leoshtika\libs\Sqlite;
use leoshtika\libs\UserFaker;
$sqliteFile = 'demo.sqlite';
// Create the database if not exists
UserFaker::create($sqliteFile);
$dbh = Sqlite::connect($sqliteFile);
$sth = $dbh->prepare('SELECT * FROM user');
$sth->execute();
$users = $sth->fetchAll(PDO::FETCH_ASSOC);
foreach ($users as $user) {
echo $user['name'] . ' Email: ' . $user['email'];
echo '
';
}
Connect to a MySQL database
require_once 'vendor/autoload.php';
use leoshtika\libs\Mysql;
$config = array(
'host' => 'localhost',
'dbname' => 'myapp',
'user' => 'root',
'pass' => '',
);
$dbh = Mysql::connect($config);
$sth = $dbh->prepare('SELECT * FROM user');
$sth->execute();
$users = $sth->fetchAll(PDO::FETCH_ASSOC);
foreach ($users as $user) {
echo $user['name'] . ' Email: ' . $user['email'];
echo '
';
}
Enjoy!, (*2)
dev-master
9999999-dev
A lightweight wrapper around PDO
Sources
Download
MIT
The Requires
The Development Requires
dev-develop
dev-develop
A lightweight wrapper around PDO
Sources
Download
MIT
The Requires
The Development Requires
v1.1.2
1.1.2.0
A lightweight wrapper around PDO
Sources
Download
MIT
The Requires
The Development Requires
v1.1.1
1.1.1.0
A lightweight wrapper around PDO
Sources
Download
MIT
The Requires
The Development Requires
v1.1.0
1.1.0.0
A lightweight wrapper around PDO
Sources
Download
MIT
The Requires
The Development Requires
v1.0.0
1.0.0.0
A lightweight wrapper around PDO
Sources
Download
MIT
The Requires
The Development Requires
v0.0.1
0.0.1.0
A lightweight wrapper around PDO
Sources
Download
MIT
The Requires
The Development Requires