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

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

->insert()

->insert() -- Insert current objects variables into database

Description

Insert the data into the database, based on the variable values of the current object and returns the ID of the inserted element if sequences or primary keys are being used. The values are correctly quoted, and some limited type checking is done.

With mysql, the mysql_next_id() method is used, on other databases, PEAR DB sequence method is used.

Note, insert() may not return the ID correctly in quite a few situations:

  • If the database backend does not support it.

  • The generator did not correctly flag the correct column as autoincrement/nextval

  • An error occured (turn on debugging to see it)

  • The insert failed or '0' rows where affected.

Return value

mixed - Id or key

Note

This function can not be called statically.

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

Download Documentation Last updated: Sun, 29 Jun 2008
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
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);
}