vrana           Tue Sep 20 08:50:11 2005 EDT

  Modified files:              
    /phpdoc/en/language/oop5    magic.xml 
  Log:
  Sleep and wakeup example (bug #34397)
  
http://cvs.php.net/diff.php/phpdoc/en/language/oop5/magic.xml?r1=1.10&r2=1.11&ty=u
Index: phpdoc/en/language/oop5/magic.xml
diff -u phpdoc/en/language/oop5/magic.xml:1.10 
phpdoc/en/language/oop5/magic.xml:1.11
--- phpdoc/en/language/oop5/magic.xml:1.10      Sun Aug  7 07:33:49 2005
+++ phpdoc/en/language/oop5/magic.xml   Tue Sep 20 08:50:10 2005
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.10 $ -->
+<!-- $Revision: 1.11 $ -->
  <sect1 id="language.oop5.magic">
   <title>Magic Methods</title>
   <para>
@@ -60,6 +60,44 @@
     during serialization and perform other reinitialization
     tasks.
    </para>
+   <example>
+    <title>Sleep and wakeup</title>
+    <programlisting role="php">
+<![CDATA[
+<?php
+class Connection {
+    protected $link;
+    private $server, $username, $password, $db;
+    
+    public function __construct($server, $username, $password, $db)
+    {
+        $this->server = $server;
+        $this->username = $username;
+        $this->password = $password;
+        $this->db = $db;
+        $this->connect();
+    }
+    
+    private function connect()
+    {
+        $this->link = mysql_connect($this->server, $this->username, 
$this->password);
+        mysql_select_db($this->db, $this->link);
+    }
+    
+    public function __sleep()
+    {
+        mysql_close($this->link);
+    }
+    
+    public function __wakeup()
+    {
+        $this->connect();
+    }
+}
+?>
+]]>
+    </programlisting>
+   </example>
   </sect2>
 
   <sect2 id="language.oop5.magic.tostring">

Reply via email to