473,414 Members | 1,626 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

serializing objects that hold other objects

Hi!
I have been thinking (not testing yet) what happens if I have something
like:

class a
{ ...}
class b
{ var a_item = new a(); ...}

$john = new b();
$ser = serialize($john);

Is the definition of class a also serialized with john and definition of
class b?

- Perttu Pulkkinen, Finland
Jul 17 '05 #1
3 2133

"Perttu Pulkkinen" <pe**************@co.jyu.fi> wrote in message
news:dq************@read3.inet.fi...
Hi!
I have been thinking (not testing yet) what happens if I have something
like:

class a
{ ...}
class b
{ var a_item = new a(); ...}

$john = new b();
$ser = serialize($john);

Is the definition of class a also serialized with john and definition of
class b?

- Perttu Pulkkinen, Finland


Yes, class a will be serialized as a property of class b (John)

regards,
Jon
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.569 / Virus Database: 360 - Release Date: 26/01/2004
Jul 17 '05 #2
No, the class definition is not stored. If you unserialize the string before
the class is defined the object will become of the class
__PHP_Incomplete_Class.

Uzytkownik "Perttu Pulkkinen" <pe**************@co.jyu.fi> napisal w
wiadomosci news:dq************@read3.inet.fi...
Hi!
I have been thinking (not testing yet) what happens if I have something
like:

class a
{ ...}
class b
{ var a_item = new a(); ...}

$john = new b();
$ser = serialize($john);

Is the definition of class a also serialized with john and definition of
class b?

- Perttu Pulkkinen, Finland

Jul 17 '05 #3
"Chung Leong" <ch***********@hotmail.com> wrote in message news:<GJ********************@comcast.com>...
No, the class definition is not stored. If you unserialize the string before
the class is defined the object will become of the class
__PHP_Incomplete_Class.

Uzytkownik "Perttu Pulkkinen" <pe**************@co.jyu.fi> napisal w
wiadomosci news:dq************@read3.inet.fi...
Hi!
I have been thinking (not testing yet) what happens if I have something
like:

class a
{ ...}
class b
{ var a_item = new a(); ...}

$john = new b();
$ser = serialize($john);

Is the definition of class a also serialized with john and definition of
class b?

- Perttu Pulkkinen, Finland


You are always required to define your class before serialize or
unserialize operation.
If defined you can serialize and unserialize all objects (even with
child objects). But you can not properly serialize and unserialize a
class with some php resource as its member.

Hope it will help.

--
Rahul Anand
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ivo Bronsveld | last post by:
All, I have quite a challenging task ahead of me. I need to write an object model (for code access) based on a schema, which cannot be made into a dataset because of it's complexity. So I...
10
by: copx | last post by:
I want to save a struct to disk.... as plain text. At the moment I do it with a function that just writes the data using fprintf. I mean like this: fprintf(fp, "%d %d", my_struct.a, my_struct.b)...
2
by: Tobias Zimmergren | last post by:
Hi, just wondering what serializing really is, and howto use it? Thanks. Tobias __________________________________________________________________ Tobias ICQ#: 55986339 Current ICQ status: +...
4
by: Dave Veeneman | last post by:
When does serializing objects make more sense than persisting them to a database? I'm new to object serialization, and I'm trying to get a feel for when to use it. Here is an example: I'm...
0
by: Ken Allen | last post by:
I am relatively new to C# and .Net in general, but have been programming in many other languages for more years than I want to recall. I have a problem where an existing set of code (actually a...
5
by: Craig Buchanan | last post by:
I have a class called LineItems. It implements IEnumerable. It uses an ArrayList to hold objects. When I try to serialize the object that contains LineItems (an object called Order), I get an...
6
by: Kyle Teague | last post by:
What would give better performance, serializing a multidimensional array and storing it in a single entry in a table or storing each element of the array in a separate table and associating the...
47
by: Max | last post by:
Due to the behaviour of a particular COM object, I need to ensure that a request for a particular ASP page is finalized before another request for the page is processed. Does IIS have a way to...
1
by: falcon198198 | last post by:
Greetings: I was hoping for some advice on an application. Here is what I am working on: Basically I have a bigger application that is having a printing problem making multiple copies of a pdf...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.