0

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.

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by Stefano Mtangoo
1

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

Edited by Stefano Mtangoo: n/a

Votes + Comments
Nice one Ev - I'll probably be back to pick your brains some more :)
0

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.

Edited by diafol: n/a

0

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!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.