Re: [PHP] Objects and Arrays Conversion

2008-12-03 Thread Nathan Nobbe
On Tue, Dec 2, 2008 at 7:48 PM, Micah Gersten <[EMAIL PROTECTED]> wrote: > VamVan wrote: > > Hello All, > > > > I was stuck with this issue. So just felt the need to reach out to other > > strugglers. > > May be people might enjoy this: > > > > Here is the code for object to array and array to obj

Re: [PHP] Objects and Arrays Conversion

2008-12-02 Thread Micah Gersten
VamVan wrote: > Hello All, > > I was stuck with this issue. So just felt the need to reach out to other > strugglers. > May be people might enjoy this: > > Here is the code for object to array and array to object conversion: > > function object_2_array($data) > { > if(is_array($data) || is_obje

Re: [PHP] Objects and Traversing

2008-06-04 Thread Jim Lucas
VamVan wrote: Hello Guys, Here is the object. How can I get access to the [Name] = access. People who help me with this can you please tell me what is the logic behind traversing the objects and how do you gather the values. Thanks. I am looking for an answer like this $queryResult->f->dsfsd

Re: [PHP] Objects and Traversing

2008-06-04 Thread Ted Wood
You should be able to access the "Name" field using this syntax: QueryResult->records[0]->sobjects[0]->fields->Name Reading from left-to-right: 1. accessing index 0 (zero) of the "records" array. 2. accessing index 0 (zero) of the "objects" array. 3. accessing the "Name" property of the "fields

Re: [PHP] objects stored in sessions

2008-04-08 Thread Julien Pauli
Just a customer of mine who said that he'll be running PHP 4 and 5 on the same server, and that he would share session data ;-) Bye. Julien.P 2008/4/7 Richard Heyes <[EMAIL PROTECTED]>: > Have you seen how PHP makes difference between private, protected and > > public > > attributes of an object

Re: [PHP] objects stored in sessions

2008-04-07 Thread Richard Heyes
Have you seen how PHP makes difference between private, protected and public attributes of an object, into the session file ? There are special caracters before them to recognize them. So the question is : is PHP4 able to read such a session file ? And how will it interpret them when we ask him t

Re: [PHP] objects stored in sessions

2008-04-07 Thread Julien Pauli
Have you seen how PHP makes difference between private, protected and public attributes of an object, into the session file ? There are special caracters before them to recognize them. So the question is : is PHP4 able to read such a session file ? And how will it interpret them when we ask him to

Re: [PHP] objects stored in sessions

2008-04-06 Thread Kevin Waterson
On Sun, 2008-04-06 at 11:02 -0400, Mark Weaver wrote: > So, if I create a user object, set the properties of said user object > and store that object in the user session will that object be available > throughout the application from the session? http://phpro.org/tutorials/Introduction-To-PHP-

Re: [PHP] objects stored in sessions

2008-04-06 Thread Mark Weaver
Richard Heyes wrote: So, if I create a user object, set the properties of said user object and store that object in the user session will that object be available throughout the application from the session? Yes. Just remember to include the class definition before you start the session on su

Re: [PHP] objects stored in sessions

2008-04-06 Thread Richard Heyes
So, if I create a user object, set the properties of said user object and store that object in the user session will that object be available throughout the application from the session? Yes. Just remember to include the class definition before you start the session on subsequent pages, otherw

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

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-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-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-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 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
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 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 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 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 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-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-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 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

2007-08-08 Thread Nathan Nobbe
On 8/8/07, Richard Lynch <[EMAIL PROTECTED]> wrote: > > On Tue, July 31, 2007 8:40 am, Eric Butera wrote: > > On 7/31/07, Nathan Nobbe <[EMAIL PROTECTED]> wrote: > >> i > >> feel sorry for Richard; if youd ever seen a successful > >> implementation of > >> design patterns in the wild > >> well you

Re: [PHP] Objects

2007-08-07 Thread Robert Cummings
On Tue, 2007-08-07 at 23:44 -0500, Richard Lynch wrote: > > I'm not trying to be a jerk or pick a fight here, but am suggesting > list members think about this before they post. Especially that whole > PHP-Editors thread, which always consists of one person from each camp > posting their favorite

Re: [PHP] Objects

2007-08-07 Thread Richard Lynch
On Tue, July 31, 2007 8:40 am, Eric Butera wrote: > On 7/31/07, Nathan Nobbe <[EMAIL PROTECTED]> wrote: >> i >> feel sorry for Richard; if youd ever seen a successful >> implementation of >> design patterns in the wild >> well you would probly feel like i do... gotta have em :) This post is a res

Re: [PHP] Objects

2007-07-31 Thread Nathan Nobbe
well im not trying to convince everyone to start doing oop, just because i dont have time. maybe if i get rich and have time ill go on a dedicated mission or something. anyway i think its obvious that objects are powerful. look at the big php projects out there; wikipedia, facebook, many of the n

Re: [PHP] Objects

2007-07-31 Thread tedd
At 1:25 AM -0500 7/31/07, Richard Lynch wrote: On Sun, July 29, 2007 12:45 pm, Nathan Nobbe wrote: one of the hardest parts about using design patterns in reality is you have to be able to recognize a certain problem and then you can begin to understand how to apply a particular pattern or

Re: [PHP] Objects

2007-07-31 Thread Eric Butera
On 7/31/07, Nathan Nobbe <[EMAIL PROTECTED]> wrote: > > On 7/31/07, Richard Lynch <[EMAIL PROTECTED]> wrote: > > Or, in my experience with pattern zealots, mis-recognize a problem as > > a pattern it isn't, mis-apply the "solution" and then spend years > > dealing with a square peg in a round hole.

Re: [PHP] Objects

2007-07-31 Thread Nathan Nobbe
> On 7/31/07, Richard Lynch <[EMAIL PROTECTED]> wrote: > Or, in my experience with pattern zealots, mis-recognize a problem as > a pattern it isn't, mis-apply the "solution" and then spend years > dealing with a square peg in a round hole... The funny thing about that is w/ OOP and design patterns

Re: [PHP] Objects

2007-07-30 Thread Richard Lynch
On Sun, July 29, 2007 12:45 pm, Nathan Nobbe wrote: > one of the hardest parts about using design patterns in reality is you > have > to be able to recognize a certain > problem and then you can begin to understand how to apply a particular > pattern or set of patterns to your > solution. Or, in m

Re: [PHP] Objects

2007-07-29 Thread Nathan Nobbe
tedd, have you looked at the book we're talking about? also, there are several other books on design patterns available, but the Heads First book is one ive heard mentioned a lot. you can check out a really sweet site online phppatterns.com; in particular follow the design link on the right hand n

Re: [PHP] Objects

2007-07-29 Thread tedd
At 2:00 PM -0400 7/25/07, Nathan Nobbe wrote: yes well at the beginning of the design patterns book they basically explain the same thing. if you dont understand the basic oo priciples, then design patterns arent going to make any sense. these basic concepts are (not looking in the book [testing

Re: [PHP] Objects

2007-07-27 Thread Nathan Nobbe
> On 7/27/07, Richard Lynch <[EMAIL PROTECTED]> wrote: > And the practical issues, well, few OOP courses really dive into that, > to tell you the truth... This is why the study of design patterns is so important, imho. -nathan On 7/27/07, Richard Lynch <[EMAIL PROTECTED]> wrote: > > On Wed, July

Re: [PHP] Objects

2007-07-26 Thread Richard Lynch
On Wed, July 25, 2007 6:33 am, Suporte - DPRJ Sistemas wrote: > Is there anyone here interested in teaching (lond distance, off > course) OOP? > > I would like to learn how to use objects (I have been working all my > life using structured language). All the books I have tried just > "talk" about t

Re: [PHP] Objects

2007-07-25 Thread Eric Butera
On 7/25/07, Nathan Nobbe <[EMAIL PROTECTED]> wrote: Eric, i was referring to the exact book you mentioned. here is an excerpt from page 32 of the book: ' we assume you know the oo basics of using classes polymorphically, how inheritance is like design by contract, and how encapsulation works.

Re: [PHP] Objects

2007-07-25 Thread Nathan Nobbe
Eric, i was referring to the exact book you mentioned. here is an excerpt from page 32 of the book: ' we assume you know the oo basics of using classes polymorphically, how inheritance is like design by contract, and how encapsulation works. if you are a little rusty on these, pull out your hea

Re: [PHP] Objects

2007-07-25 Thread Eric Butera
On 7/25/07, Tony Marston <[EMAIL PROTECTED]> wrote: Design patterns will just confuse the issue. If you come from a non-OO background (just like me) and want to know what all this OO stuff is about you might want to take a look at the following: http://www.tonymarston.net/php-mysql/good-bad-oop.h

Re: [PHP] Objects

2007-07-25 Thread Nathan Nobbe
yes well at the beginning of the design patterns book they basically explain the same thing. if you dont understand the basic oo priciples, then design patterns arent going to make any sense. these basic concepts are (not looking in the book [testing myself]..) encapsulation abstraction polymorphi

Re: [PHP] Objects

2007-07-25 Thread Tony Marston
Design patterns will just confuse the issue. If you come from a non-OO background (just like me) and want to know what all this OO stuff is about you might want to take a look at the following: http://www.tonymarston.net/php-mysql/good-bad-oop.html http://www.tonymarston.net/php-mysql/hero-or-her

Re: [PHP] Objects

2007-07-25 Thread Nathan Nobbe
eric is exactly right; design patterns are key; and so is that book ;) -nathan On 7/25/07, Eric Butera <[EMAIL PROTECTED]> wrote: On 7/25/07, Suporte - DPRJ Sistemas <[EMAIL PROTECTED]> wrote: > Hello! > > Is there anyone here interested in teaching (lond distance, off course) OOP? > > I would

Re: [PHP] Objects

2007-07-25 Thread Eric Butera
On 7/25/07, Suporte - DPRJ Sistemas <[EMAIL PROTECTED]> wrote: Hello! Is there anyone here interested in teaching (lond distance, off course) OOP? I would like to learn how to use objects (I have been working all my life using structured language). All the books I have tried just "talk" about

RE: [PHP] Objects

2007-07-25 Thread Jay Blanchard
[snip] Is there anyone here interested in teaching (lond distance, off course) OOP? I would like to learn how to use objects (I have been working all my life using structured language). All the books I have tried just "talk" about theory not practical issues. I intend to pay for the classes. [/sn

Re: [PHP] objects destroyed in same order as created?

2005-07-21 Thread Jasper Bryant-Greene
Shaw, Chris - Accenture wrote: Jasper, I would have thought php would have called the destructors on each of the classes in a LIFO fashion, but if it doesn't, just use unset() as a workaround, where you can remove the classes in the order you want. I should add that this behaviour seems to hav

RE: [PHP] objects destroyed in same order as created?

2005-07-21 Thread Shaw, Chris - Accenture
Jasper, I would have thought php would have called the destructors on each of the classes in a LIFO fashion, but if it doesn't, just use unset() as a workaround, where you can remove the classes in the order you want. C. -Original Message- From: Jasper Bryant-Greene [mailto:[EMAIL PROTE

Re: [PHP] Objects and Performance

2005-06-09 Thread Greg Donald
On 6/9/05, Matthew Weier O'Phinney <[EMAIL PROTECTED]> wrote: > Actually, that is the point. If I decide the write a script, and it is my idea, then the point of the script is my own. It's a simple benchmark. I doubt a client would ever come to me and say "Can you write me a script to add two ra

Re: [PHP] Objects and Performance

2005-06-09 Thread Matthew Weier O'Phinney
* Greg Donald <[EMAIL PROTECTED]> : > On 6/8/05, Greg Beaver <[EMAIL PROTECTED]> wrote: > > If you want to compare object methods versus functions, you should > > compare identical code inside a method to code inside a function. > > Greg's benchmarks compare two different ideological code structure

Re: [PHP] Objects and Performance

2005-06-09 Thread Greg Donald
On 6/8/05, Greg Beaver <[EMAIL PROTECTED]> wrote: > If you want to compare object methods versus functions, you should > compare identical code inside a method to code inside a function. > Greg's benchmarks compare two different ideological code structures. > Quite honestly, the wrapping of mt_sran

Re: [PHP] Objects and Performance

2005-06-08 Thread Greg Beaver
Greg Donald wrote: > On 6/8/05, NSK <[EMAIL PROTECTED]> wrote: > >>Hi, I am creating a small API in PHP, i.e. a collection of reusable functions >>for other programmers. As it is now, it is just many functions together in >>the same file. Do you think I should make it object-oriented? What are the

Re: [PHP] Objects and Performance

2005-06-08 Thread Greg Donald
On 6/8/05, NSK <[EMAIL PROTECTED]> wrote: > Hi, I am creating a small API in PHP, i.e. a collection of reusable functions > for other programmers. As it is now, it is just many functions together in > the same file. Do you think I should make it object-oriented? What are the > pros and cons of this

Re: [PHP] Objects in Arrays (without the READ prompt)

2005-05-05 Thread Jason Petersen
Hi, I think you need to serialize your objects. http://us3.php.net/manual/en/language.oop.serialization.php Jason On 5/5/05, Stuart Nielson <[EMAIL PROTECTED]> wrote: > Sorry to everyone about the stupid READ notification on the posting. I > completely forgot that it was enabled. This one s

Re: [PHP] Objects and sessions

2004-12-09 Thread Thomas Munz
I think, its not possible to init an Objeect on a session. Session will be rebuild on each reload of the site based on the session id, i think... Maybe here the object can't be rebuild anymore... > Following code: > > > class SessionTestC { > protected $value; > > function __construct (

[PHP] [SOLUTION] Re: [PHP] Objects and sessions

2004-12-09 Thread Francisco M. Marzoa Alonso
Thomas Munz wrote: I think, its not possible to init an Objeect on a session. Yes, it can. The problem was with serialization. With session.auto_start set to 1 on php.ini, seems like session's objects are unserialized before loading the script, so the class is not loaded when the session unseri

Re: [PHP] objects - is that possible at runtime in php4 or php5 ?

2004-10-04 Thread Marek Kilimajer
Alawi Albaity wrote: I want to create and defined variables of an object in runtime , is that possible ? I can do that with arrays but I want the access it as variable from obbject it self and not like member of an array are defined on object before I load it ! What about trying it before asking? -

Re: [PHP] objects within arrays

2002-12-24 Thread Beth Gore
This didn't work. Apparently from[] returns an array of objects, however I have no idea how to access the object within the array. print_r gives this: Array ( [0] => stdClass Object ( [personal] => Beth Gore [mailbox] => bethanoia [host] => habitformer.co.uk ) ) I've tried this: echo $header-

Re: [PHP] objects within arrays

2002-12-24 Thread Andrew Brampton
Big guess but I think maybe: $header[0]->from['mailbox']; Also I suggest you turn your PHP Error Level up to E_ALL in your php.ini file (or temporarly at the top of your scripts with error_reporting (E_ALL);, this will help debug programs like this :)) Andrew - Original Message - From: "

Re: [PHP] objects in an array

2002-07-13 Thread Alberto Serra
ðÒÉ×ÅÔ! Alexander Ross wrote: > I have an array filled with objects. Each object has a method called > "display". > > I have > > $var = $arr[0]; > $var->display(); > > but I keep getting an error. What am I doing wrong? > (I do a print_r of the array immediately before this code and there is

[PHP] RE: [php-objects] XML parser vs objects

2002-05-21 Thread Fredrik Davidsson
Dear Mirek, This is how we use the handler for our XML class. Hope it helps! class XML { function parseXML() { / Parse string XML data. **

Re: [PHP] objects handling objects

2002-04-04 Thread Steve Cayford
Doh, typo: // this next line would generate a parse error // print("c:a1: " . $c->echo($a)->method1() . "\n"); should read // this next line would generate a parse error // print("c:a1: " . $c->echoMethod($a)->method1() . "\n"); On Thursday, April 4, 2002, at 05:25 PM, Steve Cayford wrote:

Re: [PHP] objects handling objects

2002-04-04 Thread Steve Cayford
On Thursday, April 4, 2002, at 04:21 PM, Erik Price wrote: > I looked in the manual, but didn't see anything about this. I've read > that PHP isn't a true object-oriented language, but rather simulates > elements of object-oriented programming. Can I write a class that > performs operation

Re: [PHP] Objects and sessions

2001-11-27 Thread Tamas Arpad
On Monday 26 November 2001 23:37, Christopher William Wesley wrote: > On Mon, 26 Nov 2001, Greg Sidelinger wrote: > > Can someone tell me how to store a class in a session var. I > > want to > > There are several things you need to do. > > 1) include the class definition before you do anything >

Re: [PHP] Objects and sessions

2001-11-26 Thread Christopher William Wesley
On Mon, 26 Nov 2001, Greg Sidelinger wrote: > Can someone tell me how to store a class in a session var. I want to There are several things you need to do. 1) include the class definition before you do anything 2) start the session shortly thereafter 3) register a session variable 4) create y

Re: [PHP] Objects and sessions

2001-11-26 Thread Tamas Arpad
> later on I get errors about the class functions being undefined. > Can anyone please point me in the right direction on how to > register my objects as session vars. Class definition *must* be before any session_start() or sessgion_register() if there are previously stored objects in the se

Re: [PHP] Objects and sessions

2001-07-03 Thread Brad Hubbard
On Tue, 3 Jul 2001 11:47, Ethan Schroeder wrote: > If what you mean is if PHP sessions can register objects, that is true and > quite effective. Can you elaborate on this Ethan so I'm sure I understand what you're saying. Cheers, Brad -- PHP General Mailing List (http://www.php.net/) To unsub

Re: [PHP] Objects and sessions

2001-07-02 Thread Ethan Schroeder
If what you mean is if PHP sessions can register objects, that is true and quite effective. Ethan Schroeder - Original Message - From: "Brandon Orther" <[EMAIL PROTECTED]> To: "PHP User Group" <[EMAIL PROTECTED]> Sent: Monday, July 02, 2001 4:36 PM Subject: [PHP] Objects and sessions

Re: [PHP] objects in functions?

2001-03-11 Thread Carsten Gehling
From: "Jørg Vidar Bryne" <[EMAIL PROTECTED]> Sent: Saturday, March 10, 2001 11:52 PM > What do you mean by it fails? Any particular error, or does it just time > out? > > I've made a different recursive function to print a tree-menu, you can have > a look at it if you want but it might not be wh

Re: [PHP] objects in functions?

2001-03-10 Thread Yasuo Ohgaki
> Hi, > I want to make a recursive function generating a hierarchy using a class. > > The following code works fine when I don't wrap the function around it, > but when I do it fails. I can't figure out why... > I'm thinking I may need to make some vars global, or maybe you can't use > objects ins

Re: [PHP] objects in functions?

2001-03-10 Thread Jørg Vidar Bryne
What do you mean by it fails? Any particular error, or does it just time out? I've made a different recursive function to print a tree-menu, you can have a look at it if you want but it might not be what you're after. It prints a tree-menu, and reqires the table to have at least a field named id