LoginSignup
6
4

More than 5 years have passed since last update.

[PHP]薄くて簡単なORMを導入する場合、おすすめライブラリー「Idiorm」

Posted at

概要

新たなシステム及び既存のシステムで
フレームワークではなく、薄いORMだけを適用する場合、
薄くて簡単な「Idiorm」というライブラリー をおすすめします。

メリット

 ① : 使いやすい
 ② : いろんなQuery道具のメソッド提供
 ③ : minimalistのORMなので速度に安心
 ④ : Parisを使ったらActiverecordの形式で接近可能
 などなど

使い方法

① 設置

composer.json
"require": {
    "j4mie/idiorm": "1.5.1"
}

② ライブラリーをrequire & DB連動及び運用設定

idiorm_test.php
require_once './vendor/autoload.php';

# データベース連携設定
ORM::configure('mysql:host='.parent::HOSTNAME.';dbname='.parent::DBNAME);
ORM::configure('username', parent::USERNAME);
ORM::configure('password', parent::PASSWORD);

# ターミナルに日本語が正しく出力されるように設定
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));

④ PDO使う
ORMから提供しているメソッドたちを利用して面白くクエリーしてくれます。
ドキュメントに説明がよくされているので、ご参照してください。
🔗http://idiorm.readthedocs.org/en/latest/index.html

参考LINK

・github
🔗https://github.com/j4mie/idiorm

・公式サイトの例
🔗http://j4mie.github.io/idiormandparis/

・ドキュメント
🔗http://idiorm.readthedocs.org/en/latest/index.html

6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4