Skip to content

DBIx::Custom Documents

yuki-kimoto edited this page Oct 30, 2012 · 35 revisions

DBIx::Custom Documents

DBIx::Custom is a DBI extended class to execute insert, update, delete, and select statement easily. DBIx::Custom has many useful features. Compared to other O/R mapper modules, it is easy to learn, because DBIx::Custom has many SQL-like syntax.

This is an example.

use DBIx::Custom;

# Connect to database
my $dbi = DBIx::Custom->connect(dsn => $dsn);

# Insert
$dbi->insert({id => 1, title => 'Perl'}, table => 'book');

# Update
$dbi->update({title => 'Perl'}, table => 'book', where => {id => 1});

# Delete
$dbi->delete(table => 'book', where => {id => 1});

# Select
my $rows = $dbi->select(table => 'book')->all;

Features

DBIx::Custom have the following features.

  • Execute insert, update, delete, or select statement easily

  • Create where clause flexibly

  • Named place holder support

  • Model support

  • Connection manager support

  • Choice your favorite relational database management system, MySQL, SQLite, PostgreSQL, Oracle, Microsoft SQL Server, Microsoft Access, DB2 or anything,

  • Filtering by data type or column name

  • Create order by clause flexibly

  • Fast multiple data insert support

  • Bulk insert support (MySQL, PostgreSQL)

If you search O/R mapper like Ruby's ActiveRecord or think DBIx::Custom is very complex or think DBIx::Simple don't have enough features, I recommend DBIx::Custom for you. DBIx::Custom also have SQL generation features like SQL::Abstruct. DBIx::Custom is not depended on specific RDBMS. you can use this module with any RDMBS.

Installation

Connect to database

Query execution

Fetching rows

Where clause

Order by clause

Filter

Model

Parameter mapping

Connection manager

Performance

応用的な機能

SQLの生成

  • [http://d.hatena.ne.jp/perlcodesample/20110812/1317786773:title=select文で利用する列名を簡単に生成する column]

  • [http://d.hatena.ne.jp/perlcodesample/20110826/1318632897:title=insert文の中のvaluesの部分を動的に生成する values_clause]

  • [http://d.hatena.ne.jp/perlcodesample/20110815/1317967361:title=update文で値を代入する部分を動的に生成する]

  • [http://d.hatena.ne.jp/perlcodesample/20110720/1316138277:title=予約語のためのクォートを変更する quote]

  • [http://d.hatena.ne.jp/perlcodesample/20110801/1317036702:title=テーブル名と列名の区切り文字を変更する separator] =item * [http://d.hatena.ne.jp/perlcodesample/20110902/1319005193:title=like演算子のための値を生成する like_value]

  • [http://d.hatena.ne.jp/perlcodesample/20110923/1320306691:title=現在時刻を生成するサブルーチンの登録 now]

テーブルと列の情報

  • [http://d.hatena.ne.jp/perlcodesample/20110911/1319008159:title=すべてのテーブルを表示する show_tables]

  • [http://d.hatena.ne.jp/perlcodesample/20110825/1318591639:title=テーブルの情報を取得する get_table_info]

  • [http://d.hatena.ne.jp/perlcodesample/20110824/1318591588:title=列の情報を取得する get_column_info]

  • [http://d.hatena.ne.jp/perlcodesample/20110805/1317195340:title=データベースの列の情報を設定する user_column_info]

  • [http://d.hatena.ne.jp/perlcodesample/20110912/1319008343:title=テーブルを指定してすべての列のタイプ名を表示する show_typename]

  • [http://d.hatena.ne.jp/perlcodesample/20110910/1319008051:title=指定したテーブルのすべての列のデータタイプを表示する show_datatype]

  • [http://d.hatena.ne.jp/perlcodesample/20110810/1317638296:title=タイプ名の一覧の取得 available_typename]

  • [http://d.hatena.ne.jp/perlcodesample/20110807/1317348255:title=データタイプの一覧の取得 available_datatype]

  • [http://d.hatena.ne.jp/perlcodesample/20110804/1317125191:title=検索するテーブルから特定のテーブルを除外する exclude_table]

ユーティリティ

  • [http://d.hatena.ne.jp/perlcodesample/20110904/1319005796:title=ヘルパーメソッドを登録する helper]

  • [http://d.hatena.ne.jp/perlcodesample/20110903/1319005554:title=パラメーターをマージする merge_param]

  • [http://d.hatena.ne.jp/perlcodesample/20110907/1319006732:title=DBIx::Customオブジェクトを生成する new]

サンプル

  • [http://d.hatena.ne.jp/perlcodesample/20110620/1310369955:title=テーブルの存在を確認する]

Clone this wiki locally