Skip to content

php-crutch/database-pdo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crutch/database-pdo

Database PDO implementation

Install

composer require crutch/database-pdo

Usage

<?php

/** @var \PDO $pdo */
$database = new \Crutch\DatabasePdo\DatabasePdo($pdo);

$database->execute('INSERT INTO table (id, value) VALUES (?, ?)', [1, 'it is works']);

$query = 'SELECT * FROM table WHERE id = ?';
$oneRow = $database->fetch($query, [1]);
// $oneRow = ['id' => 1, 'value' => 'it is works'];

$allRows = $database->fetchAll($query, [1]);
// $allRows = [['id' => 1, 'value' => 'it is works']];

$database->begin();
try {
    $database->execute('DELETE FROM table WHERE id = :id', ['id' => 1]);
    $database->commit();
} catch (\Crutch\Database\Exception\StorageError $exception) {
    $database->rollback();
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages