On 2012-09-01 20:17, Kris Craig wrote:

This discussion kinda reminds me of some of the debates over AUTO_INCREMENT
behavior in the MySQL community.  Specifically, they end up having to
tackle the same funcamental, conceptual dilemma:  If I
assign/insert/whatever an arbitrary value to a container that can be
incremented, and then I direct said container to generate the next
increment, what value should that be?  What's the most sensible (or perhaps
the least unsensible) way to determine that?

Well, in that case SQL provides sequences; iterators that are independent of the column that you might be using them for. You can specify an explicit value or default to "the next value from the sequence". If you have a UNIQUE constraint on the column in question a collision would be an error (but since the attempt would have caused the sequence to advance, you could just try again); if not then you end up with two records with the same value in that column.

So, in PHP terms, pretty much what there is now - a distinct sequence generator for the array - with the difference being that in the case of key collision the later value overwrites the former.


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to