phpgroupware-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Phpgroupware-developers] proposal-branch; porting


From: Joseph Engo
Subject: Re: [Phpgroupware-developers] proposal-branch; porting
Date: Fri, 07 May 2004 17:45:54 -0400
User-agent: Mozilla Thunderbird 0.6 (Windows/20040502)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

If that database supports native reliable sequences, it will use
them.  Not all databases support them.  For example, MySQL.
PostgreSQL has build in support for
safe sequences.

If you have ever looked at the tables generated by PostgreSQL, you
will notice that when you create a field a serial, it automagicly
creates a sequence and sets your "primary key" / auto_increment field
default value to nextval('<sequence_name>').

True sequence support is very powerful for a database, you can share
them across multiple tables.  There are a ton of ways to can use them.

- - Reuse ID numbers once max sequence ID is reached.
- - Change the next value very easy and safe, setval()
- - Increment every x number ... instead of sequence++ you can do sequence+3
- - Set start and max value
etc

The reason to use genid() is not a hack.  Its just to use the best
method for id numbers for that database type.

Chris Weiss wrote:

| i'm not sure I understand this whole sequence thing.  it seems like
| a
hack for
| the guarreented, and rather simple, way to get an ID of inserting a
|
row into a
| table with auto_inc and calling a function get the last ID made by
| the connection.
|
| Joseph Engo (address@hidden) wrote:
|

| Just a follow up on this, I did some research on how ADODB handles
| sequences / last insert ID number for cross database support. - For
| MySQL, it will create a table named <sequence_id_name> and update
| that when you request the next id number. ~  This also holds true
| for any databases which don't support native sequences. -
| PostgreSQL will keep using its build in sequence support.  It will
| just do a nextval('<sequence_id_name>')
|
| Keep in mind, you *must* request an ID number *before* you do your
| insert.  At that time, you must specify the new ID number in your
| insert.
|
| I don't like how it creates a seperate table for each sequence, it
| really clutters things up.  I would prefear to create a generic
| single table to handle all of these.  However, I want to wait until
| more databases are tested to make sure its all going to fit
| together.  Presently, you must specify the PostgreSQL generated
| sequence name.  I want to develop our own naming conventions for
| this, kind of like what schemaproc does.  This will need to be
| changed in ADODB, I am going to contact that developers of the
| AXMLS and ADODB to have this added in a future release.  I want to
| make as little, if any changes to there code.  Make sure its up to
| date.
|
| If anyone is porting or working on apps for the new framework,
| please follow the above method.  Once you come up with some
| standard names, it won't be hard to make changes.
|
| Joseph Engo wrote:
|
| | Dan Kuykendall wrote: | | | Joseph Engo wrote: | |> -----BEGIN
| PGP SIGNED MESSAGE----- Hash: | SHA1 |> |> |
| $GLOBALS['phpgw']->db->get_last_insert_id() | This is | something
| |> I need to add.  Its very easy to do for PostgreSQL, | but MySQL
| is |> more of a pain.  For now, I am just doing a select | after I
| add |> the record.  Which will be fixed later once |
| get_last_insert_id() |> is ported.  AdoDB doesn't, from what I |
| understand have something |> like this, or its something they |
| removed over time for whatever |> reason. | | | Why do you think it
|  | was removed? | | |
| http://phplens.com/lens/adodb/docs-adodb.htm#inserted_id | | |
| "PostgreSQL returns the OID, which can change on a database |
| reload." - The OID number is useless to an app developer, it |
| doesn't return the last insert ID like you think it would.  The OID
|  | number is a unique number for every insert and update, which can
| be | later referenced to an action. | |
|
| _______________________________________________
| Phpgroupware-developers mailing list
| address@hidden
| http://mail.gnu.org/mailman/listinfo/phpgroupware-developers
|
|

_______________________________________________
Phpgroupware-developers mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/phpgroupware-developers




| _______________________________________________
| Phpgroupware-developers mailing list
| address@hidden
| http://mail.gnu.org/mailman/listinfo/phpgroupware-developers


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAnAOR/AzmiD/o0voRAhniAJwJCGugfbZjlX7FniFlE4k23GVbUgCfRVHu
2ABaTJzWMYqX9UA6eWgJy64=
=lV/g
-----END PGP SIGNATURE-----





reply via email to

[Prev in Thread] Current Thread [Next in Thread]