2017 © Pedro Peláez
 

library sapphire-beans

image

app2641/sapphire-beans

  • Tuesday, January 13, 2015
  • by app2641
  • Repository
  • 2 Watchers
  • 0 Stars
  • 4,048 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 3 % Grown

The README.md

SapphireBeans

SapphireBeans は俺々データベースクラスだ。, (*1)

設定ファイルの準備

まず、任意の場所に database.ini ファイルを生成する。, (*2)

[develop]
db       = "database_name"
host     = "localhost"
username = "root"
password = "root"

[production:develop]
host     = "xxx.xxx.xxx.xxx"

DB_INI_FILE 定数に database.ini へのパスを指定する。, (*3)

define('DB_INI_FILE', '/path/to/database.ini');

Helper クラス

Helper クラスからデータベースへ接続をする。, (*4)

<?php
use Sapphire\Database\Helper;

$db   = Helper::connection('develop');
$sql  = 'SELECT * FROM user WHERE user.name = ?';
$user = $db->build($sql, 'hoge')->fetch();

Registry クラス

一度、Helper から接続できれば Registy クラスを介して接続を取得出来る。, (*5)

<?php
use Sapphire\Utility\Registry;

$db  = Registry::get('db');
$sql = 'UPDATE user SET name = ?, furigana = ?';
$db->build($sql, array('piyo', 'ぴよ'));

入れ子トランザクション

トランザクションを入れ子で動かすことが出来る。, (*6)

<?php
use Sapphire\Utility\Registry;
$db = Registry::get('db');

try {
    $db->beginTransaction();

    try {
        $db->beginTransaction();
        $db->commit();

    } catch (\Exception) {
        $db->rollBack();
        throw $e;
    }

    $db->commit();

} catch (\Exception $e) {
    $db->rollBack();
    throw $e;
}

The Versions

13/01 2015

dev-master

9999999-dev

  Sources   Download

The Requires

  • php >=5.4

 

01/05 2014

0.2

0.2.0.0

  Sources   Download

The Requires

  • php >=5.4

 

01/05 2014

dev-develop

dev-develop

  Sources   Download

The Requires

  • php >=5.4

 

01/05 2014

0.1

0.1.0.0

  Sources   Download

The Requires

  • php >=5.4