previous導入 - 取得 (Previous) (Next) 導入 - 実行next

View this page in Last updated: Sun, 21 Jun 2009
English | Brazilian Portuguese | Chinese | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Turkish

導入 - シーケンス

導入 - シーケンス – データベースのシーケンス

説明

シーケンスとは、データの行に一意な ID を提供するための仕組みのひとつです。 たとえば MySQL を使用されているかたなら、いわゆる AUTO_INCREMENT のようなものと考えればよいでしょう。 仕組みはきわめてシンプルです。まず ID を要求し、 新しく作成した行の ID フィールドにその値を挿入します。 複数のテーブルに対して複数のシーケンスを使用することができますが、 ひとつのテーブルに対しては常に同じシーケンスを用いるようにしてください。 一意な ID の値を取得するには nextId() を使用します。シーケンスが存在しない場合は、自動的に作成されます。

シーケンスの使用

<?php
...
$id $db->nextId('mySequence');
// INSERT クエリで ID を使用します
$res $db->query("INSERT INTO myTable (id,text) VALUES ($id,'foo')");
...
?>
previous導入 - 取得 (Previous) (Next) 導入 - 実行next

Download Documentation Last updated: Sun, 21 Jun 2009
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
There are no user contributed notes for this page.