LoginSignup
2
4

More than 5 years have passed since last update.

PHP製軽量ORM Idiormの使い方例

Last updated at Posted at 2016-04-28

軽量でちょっとしたスクラッチプログラムにて
簡易なDBからデータ抽出するには楽なライブラリ。

ドキュメントこちら

Welcome to Idiorm’s documentation!
http://idiorm.readthedocs.org/

$result = ORM::for_table('entries')
    // 複数セレクト
    ->select_many(
    'id',
    'name',
    'kana',
    'group_name',
    'group_kana',
    'tel',
    'email',
    // フィールド名エイリアス(エイリアス名,フィールド名)
    array('tel_mobile'=>'moblile'),
    );



//join
$result = ORM::for_table('entries')
    ->left_outer_join('entry_members', 'entries.id=entry_members.entry_id')

    //検索条件
    ->where('name', 'Fred Bloggs')

    // 否定
    ->where_not_equal(array(
        'entry_members.name' => '',
    ));

//SQL直クエリ
$query = 'SELECT * FROM entries WHERE event_name = :event_name';
$entries = ORM::for_table('entries')
    ->raw_query($query, array('event_name' => $event_name))
    ->find_array();

2
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
2
4