Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/attogram/database
SQLite database access for PHP 7. Small, one class, and highly opinionated.
https://github.com/attogram/database
php-database-class php-database-connection php7 sqlite
Last synced: about 18 hours ago
JSON representation
SQLite database access for PHP 7. Small, one class, and highly opinionated.
- Host: GitHub
- URL: https://github.com/attogram/database
- Owner: attogram
- License: mit
- Created: 2019-04-17T20:25:28.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-15T20:34:58.000Z (almost 5 years ago)
- Last Synced: 2024-07-04T23:50:24.765Z (4 months ago)
- Topics: php-database-class, php-database-connection, php7, sqlite
- Language: PHP
- Homepage: https://attogram.github.io/database/
- Size: 11.7 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Attogram Database
SQLite database access for PHP 7. Small, one class, and highly opinionated.
[![Maintainability](https://api.codeclimate.com/v1/badges/473e68db98ac442429c1/maintainability)](https://codeclimate.com/github/attogram/database/maintainability)
[![Build Status](https://travis-ci.org/attogram/database.svg?branch=master)](https://travis-ci.org/attogram/database)
[![Latest Stable Version](https://poser.pugx.org/attogram/database/v/stable)](https://packagist.org/packages/attogram/database)## Install
```
composer require attogram/database
```## Examples
one table:
```php
declare(strict_types = 1);use Attogram\Database\Database;
require '../vendor/autoload.php';
$database = new Database();
$database->setDatabaseFile('./test.one.sqlite');
$database->setCreateTables("CREATE TABLE 'one' ('foo' TEXT)");try {
$database->raw("INSERT INTO one ('foo') VALUES (CURRENT_TIMESTAMP)");
$arrayResults = $database->query("SELECT * FROM 'one'");
print_r($arrayResults);
} catch (Throwable $error) {
print 'ERROR: ' . $error->getMessage();
}
```two tables:
```php
declare(strict_types = 1);use Attogram\Database\Database;
require '../vendor/autoload.php';
$database = new Database();
$database->setDatabaseFile('./test.two.sqlite');$tables = [
"CREATE TABLE 'one' ('foo' TEXT)",
"CREATE TABLE 'two' ('bar' TEXT)",
];
$database->setCreateTables($tables);try {
$database->raw("INSERT INTO one ('foo') VALUES (CURRENT_TIMESTAMP)");
$database->raw("INSERT INTO two ('bar') VALUES (CURRENT_TIMESTAMP)");
$arrayResults = $database->query("SELECT * FROM 'one'");
print_r($arrayResults);
$arrayResults = $database->query("SELECT * FROM 'two'");
print_r($arrayResults);
} catch (Throwable $error) {
print 'ERROR: ' . $error->getMessage();
}
```