?php class FileStorage {var $data; function FileStorage($data) {$this - data = $data;} function write($name) {$fp = fopen(name, "w"); fwrite($fp, $this - data); fclose($data);}} class WDDXStorage {var $data; var $version = "1.0"; var $_id; / / "private "variable function WDDXStorage($data) {$this - data = $data; $this - _id = $this - _genID();} function store() {if ($this - _id) {$pid = wddx_packet_start($this - _id); wddx_add_vars($pid, "this - data"); $packet = wddx_packet_end($pid);} else {$packet = wddx_serialize_value($this - data);} $dbh = dba_open("varstore", "w", "gdbm"); dba_insert(md5(uniqid("",true)), $packet, $dbh); dba_close($dbh);} / / a private method function _genID() {return md5(uniqid(rand(),true));}} class DBStorage {var $data; var $dbtype = "mysql"; function DBStorage($data) {$this - data = $data;} function save() {$dbh = mysql_connect(); mysql_select_db("storage", $dbh); $serdata = serialize($this - data); mysql_query("insert into vars ('$serdata',now())", $dbh); mysql_close($dbh);}}?
?php class FileStorage {var $data; function FileStorage($data) {$this - data = $data;} function write($name) {$fp = fopen(name, "w"); fwrite($fp, $this - data); fclose($data);}} class WDDXStorage {var $data; var $version = "1.0"; var $_id; / / variable "priv eacute;e "function WDDXStorage($data) {$this - data = $data; $this - _id = $this - _genID();} function store() {if ($this - _id) {$pid = wddx_packet_start($this - _id); wddx_add_vars($pid, "this - data"); $packet = wddx_packet_end($pid);} else {$packet = wddx_serialize_value($this - data);} $dbh = dba_open("varstore", "w", "gdbm"); dba_insert(md5(uniqid("",true)), $packet, $dbh); dba_close($dbh);} / / m eacute;thode priv eacute;e function _genID() {return md5(uniqid(rand(),true));}} class DBStorage {var $data; var $dbtype = "mysql"; function DBStorage($data) {$this - data = $data;} function save() {$dbh = mysql_connect(); mysql_select_db("storage", $dbh); $serdata = serialize($this - data); mysql_query("insert into vars ('$serdata',now())", $dbh); mysql_close($dbh);}}?