Member Avatar for diafol

Hi all,

Trying to get my head around OOP at long last. Finally got to the beggar on my to-do list.

Just a quick question:

I was looking for a way to persist the object across pages, but on further research, I got the idea that this is a bad idea and that objects should be created anew on every page. Does this also apply to Ajax calls (I assume it does)? Seems like a lot of work for a straightforward part-of-page-update. I haven't got a specific use in mind, still at the concept stage.

Just thinking of all the include files req'd by a simple php script on a round trip from the client. Any thoughts on this? I'm noob^infinity on OOP.

Recommended Answers

All 3 Replies

Hi all,

Trying to get my head around OOP at long last. Finally got to the beggar on my to-do list.

Welcome to the world of beasts ;)

Just a quick question:

I was looking for a way to persist the object across pages, but on further research, I got the idea that this is a bad idea and that objects should be created anew on every page. Does this also apply to Ajax calls (I assume it does)? Seems like a lot of work for a straightforward part-of-page-update. I haven't got a specific use in mind, still at the concept stage.

Why would you want to persists objects across the page? Since technically AJAX call is just like other calls with no reloading of page then things goes just like the non Ajax page. I think that should be avoided and alternative is given below. If you persist on testing the concept, check serialize/unserialize and this one

Just thinking of all the include files req'd by a simple php script on a round trip from the client. Any thoughts on this? I'm noob^infinity on OOP.

I think the best way would be storing in session key (like ID) to a table containing info necessary to create an object. Then query the info and create an object that will persist per each page.

I just tried google and here is an interesting thread

commented: Nice one Ev - I'll probably be back to pick your brains some more :) +13
Member Avatar for diafol

Hi Ev, good answer - I saw a few things about carrying over a session var with just id and then getting the whole caboodle again. I was just thinking about having to include a shed full of classes for what would be a trivial update. My fault, I need to seriously get my head out of my derriere and start thinking OOP instead of procedural.

As for persisting with persistence, I think I can safely let that idea slip now. Still, I feel like I'm looking up at Everest from sea level.

Thanks for the links.

Hi Ev, good answer - I saw a few things about carrying over a session var with just id and then getting the whole caboodle again. I was just thinking about having to include a shed full of classes for what would be a trivial update. My fault, I need to seriously get my head out of my derriere and start thinking OOP instead of procedural.

As for persisting with persistence, I think I can safely let that idea slip now. Still, I feel like I'm looking up at Everest from sea level.

Thanks for the links.

Glad that I was of help,
enjoy!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.