2017 © Pedro Peláez
 

library sqwrapper

small sqlite PDO wrapper

image

theoldmoon0602/sqwrapper

small sqlite PDO wrapper

  • Thursday, February 9, 2017
  • by theoldmoon0602
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

sqwrapper

sqwrapper is a small sqlite PDO wrapper, (*1)

Usage

<?php
require_once('vendor/autoload.php');
use sqwrapper\Model;
use sqwrapper\DB;

class User extends Model {
    public function setschema() {
        $this->setname('users');

        $this->number('id')->autoincrement()->unique()->noform();
        $this->text('name')->unique();
        $this->password('password')->setinserthook(function($v) {
            return password_hash($v['value'], PASSWORD_DEFAULT);
        });
    }
}

DB::$dbname = 'database.db';
$pdo = DB::connect();
$pdo->exec((new User())->getschema());

(new User())->register([
    'name' => 'username',
    'password' => 'password'
]);

When you saved above script as hoge.php, after you executed php hoge.php we got below result., (*2)

sqlite3 database.db, (*3)

sqlite> .schema
CREATE TABLE `users`(
    `id` `int` not null unique,
    `name` `text` not null unique,
    `password` `text` not null
);
sqlite> select * from users;
1|username|$2y$10$qes1LSAp5ONLcqP1ozFjZub1jUAulImQgjlvqmv9wEOY8LlHASfG6

The Versions

09/02 2017

dev-master

9999999-dev

small sqlite PDO wrapper

  Sources   Download

Apache

The Requires

  • php >=7.0

 

The Development Requires

by Avatar theoldmoon0602