Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
attogram committed May 27, 2019
1 parent 7d175fe commit f96d951
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Attogram Database

SQLite database access for PHP 7. Small, one class, and highly opinionated.

* Repository: **<https://github.com/attogram/database>**

[![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();
}
```
File renamed without changes.
File renamed without changes.

0 comments on commit f96d951

Please sign in to comment.