项目作者: samayo

项目描述 :
yet another pdo wrapper
高级语言: PHP
项目地址: git://github.com/samayo/styrofoam.git
创建时间: 2013-10-04T13:52:20Z
项目社区:https://github.com/samayo/styrofoam

开源协议:MIT License

下载


Styrofoam

A tiny PDO wrapper class, for simple CRUD operation.

Install

Using composer

  1. $ composer require samayo/styrofoam:1.0.*

Using git

  1. $ git clone https://github.com/samayo/styrofoam.git

Usage

  1. require 'path/to/styrofoam.php';
  2. $db = new Styrofoam\Database(
  3. 'mysql:host=localhost; dbname=db-name; charset=utf8', 'db-user', 'db-pass', [
  4. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  5. PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
  6. ]);

Examples

SELECT

  1. // returns $select with value of query
  2. $select = $db->select('SELECT * FROM users WHERE id = ?', [145]);

INSERT

  1. // returns value lastInsertId() on success
  2. $insert = $db->insert('INSERT INTO users (lastname) VALUES (?)', ['robin']);

DELETE

  1. // returns $delete as boolean
  2. $delete = $db->delete('DELETE FROM users WHERE id = ?', [456]);

UPDATE

  1. // returns $update as boolean
  2. $update = $db->update('UPDATE cars SET color = ? WHERE model = ?', ['blue', 'Toyota']);