2017 © Pedro Peláez
 

library cfedb2

eccentric and risky, outdated ORM for PHP.

image

uzulla/cfedb2

eccentric and risky, outdated ORM for PHP.

  • Wednesday, June 29, 2016
  • by uzulla
  • Repository
  • 1 Watchers
  • 0 Stars
  • 76 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

CFEDb2

オレオレO/Rマッパー, (*1)

REQUIRE

  • PDO
  • mysql or sqlite3
  • PHP>=5.3.x

オレオレライブラリです

ながれるようにチェーンでSqlをBuildするとか、Joinがすばらしくできるとか、そういうものはありません。 設計の自由度もありません。 昔ActiveRecordをつかって、ちゃっちゃっとモデルを作るのが楽だなーって思い、当時の理解で(パラダイムの変遷を理解せず)書いてます。 しかし、ARはfind()とかjoin()とかつなぐのかったるい、いいからSQLで書かせろって思ったので、SQLBuilder系は作っていません。, (*2)

  • まずSQLをかいたほうがハヤイと思っている
  • 出てくるのがハッシュだとちょっと不便
  • DBにインサートする前にオブジェクトを作りたい
  • FatだろうがなんだろうがRowオブジェクト最高

という変わった人なら本ライブラリも良いかもしれません。, (*3)

SYNOPSIS

$post = new Post();
$post->val('text', 'this is text');
$post->val('num', 123);
$post->saveItem();

$post2 = Post::getById(1);
echo $post2->val('text');

$post3 = Post::getBySome('text', 'this is text');
if(empty($post3)){
    echo "not found";
}

$post_list = Post::getsBySQL('SELECT * FROM post WHERE id>:id', array('id'=>5));
if(empty($post_list)){
    echo "not found";
}
foreach($post_list as $p){
    echo $p->val('id');
}

$post->deleteItem();

//もし貴方がROWオブジェクト嫌いなら…

$post_list = Post::getsHashBySome('text', 'this is text');

テストコードを見てください(しかし、全部が羅列されているわけではありません), (*4)

インストール

DLして適当に配置する、または、Composerで, (*5)

{
    "require": {
        "uzulla/cfedb2": "*"
    }
}

モデルクラス例

<?php
require_once('../lib/Uzulla/CFEDb2.php'); // ComposerのAutoloaderをつかっているなら不要

class Post extends \Uzulla\CFEDb2{
    static $tablename = 'post';
    static $pkeyname = 'id';
    public function __construct() {
        $this->values['id'] = null;
        $this->values['text'] = null;
        $this->values['num'] = null;
        $this->values['created_at'] = null;
        $this->values['updated_at'] = null;
    }
    public function as_you_like(){
        return $this->val('id').' as you like!';
    }
    static function getMySpecial(){
        return static::getById(3);
    }
}

DB接続情報設定

\Uzulla\CFEDb2::$config = array(
    'type'=> 'mysql',
    // 'type'=> 'sqlite',
    'dsn' => 'host=127.0.0.1;dbname=test;charset=utf8mb4',
    // 'dsn' => 'unix_socket=/tmp/mysql.sock;dbname=test',
    // 'dsn' => __DIR__.'/sqlite.db',
    'user' => "",
    'pass' => "",
    'pre_exec' => false,
    'reuse_pdo' => true,
    'DEBUG_BACKTRACE' => true, // or false, enable backtrace log.
    'log'=> null // null will use error_log, Psr-3 logger instance(ex:monolog)
);

The Versions

29/06 2016

dev-master

9999999-dev http://github.com/uzulla/CFEDb2

eccentric and risky, outdated ORM for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

orm db

29/06 2016

v0.2.3

0.2.3.0 http://github.com/uzulla/CFEDb2

eccentric and risky, outdated ORM for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

orm db

07/04 2016

v0.2.2

0.2.2.0 http://github.com/uzulla/CFEDb2

eccentric and risky, outdated ORM for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

orm db

25/11 2014

v0.2.1

0.2.1.0 http://github.com/uzulla/CFEDb2

eccentric and risky, outdated ORM for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

orm db

24/05 2014

v0.2.0

0.2.0.0 http://github.com/uzulla/CFEDb2

eccentric and risky, outdated ORM for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

orm db

17/12 2013

v0.1.4

0.1.4.0 http://github.com/uzulla/CFEDb2

eccentric and risky, outdated ORM for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

orm db

16/12 2013

v0.1.2

0.1.2.0 http://github.com/uzulla/CFEDb2

eccentric and risky, outdated ORM for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

orm db

16/12 2013

v0.1.3

0.1.3.0 http://github.com/uzulla/CFEDb2

eccentric and risky, outdated ORM for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

orm db

10/08 2013

0.1.1

0.1.1.0 http://github.com/uzulla/CFEDb2

eccentric and risky, outdated ORM for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

orm db

24/07 2013

v0.1.0

0.1.0.0 http://github.com/uzulla/CFEDb2

eccentric and risky, outdated ORM for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

orm db

19/07 2013

v0.0.2

0.0.2.0 http://github.com/uzulla/CFEDb2

eccentric and risky, outdated ORM for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

orm db