473,770 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PLEASE detailed __sleep() and __wakeup() code for databaseconnect ion

1 New Member
I am searching for days now to get a concrete example of how to use the __sleep() and __wakeup() function in a class to restore a databaseconnect ion when passing an object from one page to another by putting it in a session-variable.

What I already know is that you should load the class before the session_start() function etc... What I DO NOT know is how the concrete code in the __sleep() and __wakeup() functions should be in order to automatically restore the database connection.

In my class I have the following database connection code in the class constructor:

$this->db = mysql_connect($ db_info[host], $db_info[username], $db_info[password])
or die ("Error connection MySQL");
mysql_select_db ($db_info[dbname], $this->db)
or die ("Database cannot be opened");

What code do I put in the __sleep() and __wakeup() functions to restore that database connection. So please fill in:

function __sleep()
{
............... .
}

function __wakeup()
{
...............
}

The only information I find on the web, in the PHP manuals and books I have is simply: "you can use the magick functions __sleep() and __wakeup() to restore a database connection when serializing an object". NO further explanation.

I am getting a bit desperate here.
Oct 25 '06 #1
1 1946
ronverdonk
4,258 Recognized Expert Specialist
Reading your request, I bet you haven't looked in the standard PHP documentation at php.net. The following link gives quite some tips and samples on using the serialize(), unserialize(), __sleep() and __wakepup functions. See The magic functions __sleep and __wakeup

Ronald :cool:
Oct 25 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1483
by: Rob Long | last post by:
Hey I'm building a webapp with tons of objects all over the place, a lot of which are quite complex, meaning they could have many subclasses and many nested object members. I'm implementing a memory caching mechanism to store these objects between requests and share them between different user sessions. In order for my memory caching mechanism to work, objects must be serialised before they are placed into the cache. In PHP5, this
0
1325
by: Jack | last post by:
Hi, I have the following problem. I have a main data entry form which has a link to a detailed data entry form. The value of the link in the main form is the sum total of all the line items in the detailed form. The detailed form has fields to capture the individual line items like contracted service expense, travel expense etc. I am capturing the total of individual line items using session variables so
8
1338
by: phil goddard | last post by:
This homework tests your understanding of pointers and how to use pointers with arrays and functions. What we want to do is find the next highest int in an array based on a given float, i.e. in the following example, based on the float 7.11 we want to find the 8. Tasks: 1) Include all the required libraries and define a main(). 2) In main, define a a. float called myFloat, initialize it with 7.11
7
1007
by: Newbie! | last post by:
Hi Group, I have a project which has a access database with it. I`ve added the Database Adapter And Database connected to each of my forms, generated a Dataset, and added the relivant table from the Database into it. Is this right or should i only add my Database Adapter and Connector once to my project? Ta
0
263
by: ECathell | last post by:
In Theory is this the correct use of a singleton object? I only want them to be able to run this process once(of course by closeing and restarting the application stops that functionality). Is this setup properly? Public Class OracleSnapshot Private Shared m_instance As OracleSnapshot Private Sub New() Try
1
9652
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
1
54535
PEB
by: PEB | last post by:
POSTING GUIDELINES Please follow these guidelines when posting questions Post your question in a relevant forum Do NOT PM questions to individual experts - This is not fair on them and we instruct our experts to ignore any such PMs completely Be sure to give the version of Access that you are working with and the Platform and OS if applicable.
1
20274
by: =?Utf-8?B?c2NvdHRybQ==?= | last post by:
I have some code to read the contents of a varbinary(max) field in SQL Server 2005. It is working ok I just wanted to know if anyone had any comments on it's efficiency. Code to read from the field using (SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess)) { if (reader.Read())
4
1333
by: jonc1 | last post by:
Can anyone explain how these work in relation to setting and application setting files. I know that application settings can not be modified programatically at runtime, although they can be changed in the XML. (I did try adding a set method in my settings.cs to allow me to update the application scoped databaseconnection string, but VS was not being foole d by that). However, I want to change my DatabaseConnection string (to point at a...
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10099
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9904
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7451
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.