->count() (Previous) (Next) ->update()

View this page in Last updated: Sun, 05 Oct 2008
English | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Plain HTML

->insert()

->insert() -- 現在のオブジェクト変数をデータベースに挿入する

説明

現在のオブジェクトの偏す打ちに基づいたデータをデータベースに挿入し、 もし、シーケンスや主キーが使用される場合、挿入された要素のIDを返します。 値は完全にクオートされ、 いくつかの制限された型のチェックは行われています。

MySQLでは mysql_next_id() メソッドが使用され、 他のデータベースでは、PEAR DB の sequence メソッドが使用されます。

注意: insert() メソッドはいくつかの状況では ID を正しく返さないかも知れません。

  • データベースバックエンドがサポートしていない場合

  • 生成スクリプトが正しいカラムを自動インクリメント/nextvalとしてマークしなかった場合

  • 何らかのエラーが発生した場合 (デバッグモードで確認することができます)

  • 挿入に失敗、あるいは '0' 行に影響を与えた場合

返り値

mixed - Id あるいは キーを指定します。

注意

この関数は、スタティックにコールする ことはできません。

->count() (Previous) (Next) ->update()

Download Documentation Last updated: Sun, 05 Oct 2008
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
Note by: Charlie Shin
I spent at least 3 days to find out why there is extra table with additional "_seq" in my database. I finally realize it is created because sequenceKey(). I don't know why bother to find sequenceKey() if my table is no need sequence key? This feature should not set by flag or option, otherwise I have to manually add in return array(false, false) each time after if package upgrade?
Note by: pierre2543@hotmail.com
By default insert() will populate key fields automatically. If you want to manage your own keys, override sequenceKey() in your DO as follows:

function sequenceKey(){
return array(false,false);
}