> markw@mohawksoft.com wrote:
>>> markw@mohawksoft.com wrote:
>>>>> On Sat, 2007-03-17 at 12:19 -0400, Mark wrote:
>>
>>>> There in lies the biggest problem with LAMP, and that's MySQL. The
>>>> architecture of your methodology *only* works with MySQL, and not more
>>>> capable databases like Oracle, DB2, or even PostgreSQL.
>>> I too thought the same thing, but was corrected when I starting working
>>> on a redesign for the billing system for the company that I am working
>>> for.  They use PostgreSQL and we do have a auto incremented unique id
>>> field.  It isn't call AUTO_INCREMENT, but rather a sequence value.  It
>>> is a value that is controlled by the default value entry.
>>>
>>> It then runs this:
>>>     nextval('customers_customer_id_seq'::regclass)
>>>
>>> and uses this as the value of the id field for the newly inserted row.
>>
>> Yea, I've been using PG for over 10 years now. Sequences are awesome,
>> but
>> there have an "auto number" column type as well. It simply creates a
>> sequence but it's there.
>>
>> I guess maybe most databases support the notion of "auto number" in some
>> form. I haven't used MSSQL recently, but I think their solution is a
>> GUID.
>>
>>> Then instead of running a command like SELECT LAST_INSERT_ID(); you
>>> have
>>> to do some other stuff like this:
>>>
>>> $SQL = "SELECT currval('{$table}_{$column}_seq');";
>>
>> Again, this is absolutely wrong unless it is wrapped in a transaction.
>> You
>> will need a "begin" and a "commit" in an MVCC type system. If you don't
>> wrap it in a transaction you don't know who got the last "nextval" of
>> the
>> sequence.
>
> Check the documentation - currval returns the last one *for that
> session* - it does not return the last global change.
>
> http://www.postgresql.org/docs/current/static/functions-sequence.html
>
> It is perfectly safe to use this.

In theory that may be true, but can the application developer make any
assumption about the underlying architecture? Might you be familiar with
connection pooling? Where multiple threads or processes share a database
connection or "session?"

I'm not a web developer. I suck at PHP, I do know PHP, I've written a
number of PHP extensions, and have had my CVS account for about 8 years,
but I'm not a web developer. I'm an architect and it is problematic when
applications developers make assumptions about things that can change.

<soap_box>
Open source is about more than simply getting the supposed job done, it is
about getting it done right too. It is about using best methods. And yes,
it is about ego and pride about doing it better.

In every profession there are many things that work within a limited range
of use, but break down quickly when the situations change subtly. A
professional knows their "craft" well enough to anticipate these things.

The authors of too many open source / GPL PHP projects take the easy way
out and ignore the larger architectural issues that would make their
projects more widely usable. How long did it take bugzilla to support
PostgreSQL? How any PHP projects on sourceforge are tied to MySQL instead
of being flexible?

Developers, either proprietary or OS/GPL, seek to create software of
lasting value. If you choose to limit your software design, then you limit
its value.
</soap_box>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to