ユーザ用ツール

サイト用ツール


symfony:dql

コマンドラインでのクエリ実行

○ DtbRoomInfo テーブルのすべてのレコードを取得
  # ./symfony doctrine:dql “FROM DtbRoomInfo”

○ DtbRoomInfo テーブルのすべてのレコードを表形式で取得
  # ./symfony doctrine:dql “FROM DtbRoomInfo” –table

○ DtbRoomInfo テーブルの room_number が 2015 の room_number を取得
  # ./symfony doctrine:dql “SELECT d.room_number FROM DtbRoomInfo d WHERE room_number LIKE ?” 2015 –table

○ DtbRoomInfo テーブルの room_number が 2015 且つ status_id が 2 の room_number と status_id を取得
  # ./symfony doctrine:dql “SELECT d.room_number,d.status_id FROM DtbRoomInfo d WHERE room_number LIKE ? and status_id = ?” 120% 2 –table

○ DtbRoomInfo テーブルと MtbStatus テーブルから room_number が 2015 の room_number と bg_color を取得
  # ./symfony doctrine:dql “SELECT d.room_number,m.bg_color FROM DtbRoomInfo d, d.MtbStatus m WHERE d.room_number LIKE ?” 2015 –table

○ DtbRoomInfo テーブルの room_number の合計を SunNum という名前で取得
  # ./symfony doctrine:dql “SELECT sum(d.room_number) AS SumNum FROM DtbRoomInfo d” –table

○ DtbRoomInfo テーブルと MtbStatus テーブルを status_id で集計した数と status_name を取得
  # ./symfony doctrine:dql “SELECT count(d.room_number),m.status_name AS SumNum FROM DtbRoomInfo d, d.MtbStatus m group by status_id” –table

symfony/dql.txt · 最終更新: 2011/05/11 08:19 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki