[PHP] Objects as array key names??

2008-03-15 Thread Jim Lucas
This question should probably be directed at the PHP Internals list, but I thought I would start by asking here first if anybody would even use this feature. It has been brought to my attention that with Perl and Ruby, you can use Objects as the value of the key within an array. The examples

Re: [PHP] Objects as array key names??

2008-03-15 Thread Ray Hauge
Jim Lucas wrote: This question should probably be directed at the PHP Internals list, but I thought I would start by asking here first if anybody would even use this feature. It has been brought to my attention that with Perl and Ruby, you can use Objects as the value of the key within an arr

Re: [PHP] Objects as array key names??

2008-03-15 Thread Jeremy Mcentire
On Mar 15, 2008, at 7:16 PM, Ray Hauge wrote: Jim Lucas wrote: It has been brought to my attention that with Perl and Ruby, you can use Objects as the value of the key within an array. The examples that were shown to me make me think that this would be an awesome ability to have within PHP

Re: [PHP] Objects as array key names??

2008-03-15 Thread Robert Cummings
On Sat, 2008-03-15 at 15:02 -0700, Jim Lucas wrote: > This question should probably be directed at the PHP Internals list, but > I thought I would start by asking here first if anybody would even use > this feature. > > It has been brought to my attention that with Perl and Ruby, you can use >

Re: [PHP] Objects as array key names??

2008-03-16 Thread Richard Heyes
Hi, Going off the subject alone, you might want to investigate the __tostring() magic method that you can define to handle objects being cast to a string. Also, there's a whole bunch of magic methods that you can use to handle PHP operations on user defined objects: http://uk.php.net/manual/

Re: [PHP] Objects as array key names??

2008-03-16 Thread Nathan Nobbe
On Sat, Mar 15, 2008 at 6:02 PM, Jim Lucas <[EMAIL PROTECTED]> wrote: > It has been brought to my attention that with Perl and Ruby, you can use > Objects as the value of the key within an array. The examples that were > shown to me make me think that this would be an awesome ability to have > wi

Re: [PHP] Objects as array key names??

2008-03-16 Thread Nathan Nobbe
after talking w/ marcus it sounds like theyve explicitly decided not to support objects in the aforementioned context. -nathan

Re: [PHP] Objects as array key names??

2008-03-16 Thread Jim Lucas
Robert Cummings wrote: Imagine 200 customers in your example... your example will hit the DB 201 times. The above hits the DB twice. My code was intended to get the concept across. Thanks for the suggestions though. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:

Re: [PHP] Objects as array key names??

2008-03-16 Thread Jim Lucas
Richard Heyes wrote: Hi, Going off the subject alone, you might want to investigate the __tostring() magic method that you can define to handle objects being cast to a string. Also, there's a whole bunch of magic methods that you can use to handle PHP operations on user defined objects: htt

Re: [PHP] Objects as array key names??

2008-03-16 Thread Robert Cummings
On Sun, 2008-03-16 at 11:42 -0700, Jim Lucas wrote: > Robert Cummings wrote: > > Imagine 200 customers in your example... your example will hit the DB > > 201 times. The above hits the DB twice. > > My code was intended to get the concept across. Thanks for the > suggestions though. Ah, ok. I'

Re: [PHP] Objects as array key names??

2008-03-16 Thread Jim Lucas
Robert Cummings wrote: On Sun, 2008-03-16 at 11:42 -0700, Jim Lucas wrote: Robert Cummings wrote: Imagine 200 customers in your example... your example will hit the DB 201 times. The above hits the DB twice. My code was intended to get the concept across. Thanks for the suggestions though.

Re: [PHP] Objects as array key names??

2008-03-16 Thread Jim Lucas
Sorry for the long post, but I thought it would explain much of my thinking... Anyway, here we go... Jeremy Mcentire wrote: You may have meant the while loop to iterate over $row = fetch_object($res) ... You are correct, I was simply trying to get the concept across. But you are correct,

Re: [PHP] Objects as array key names??

2008-03-18 Thread Nathan Nobbe
another developer brought to my attention the spl method spl_object_hash() method which afforded a mod in the previously posted class whereby foreach could be used properly. also, it allows a more efficient internal implementation. however, to my dismay, it appears that implementing ArrayAccess d

Re: [PHP] Objects as array key names??

2008-03-19 Thread Jim Lucas
Nathan Nobbe wrote: another developer brought to my attention the spl method spl_object_hash() method which afforded a mod in the previously posted class whereby foreach could be used properly. also, it allows a more efficient internal implementation. however, to my dismay, it appears that impl

Re: [PHP] Objects as array key names??

2008-03-19 Thread Nathan Nobbe
On Wed, Mar 19, 2008 at 10:37 AM, Jim Lucas <[EMAIL PROTECTED]> wrote: > I would be interested in your examples. From what you described, I can't > see in > my head how it all goes together. > there was one caveat; i had to introduce a keyVal() instance method so client code can get the object t