cvs: presentations /slides/php5intro spl.php spl.xml

From: Date: Sun, 23 Mar 2003 21:51:37 +0000
Subject: cvs: presentations /slides/php5intro spl.php spl.xml
Groups: php.pres 
Request: Send a blank email to pres+get-619@lists.php.net to get a copy of this message
sterling Sun Mar 23 16:51:37 2003 EDT Added files: /presentations/slides/php5intro spl.php spl.xml Log: add spl example Index: presentations/slides/php5intro/spl.php +++ presentations/slides/php5intro/spl.php <?php /* dba dump utility * * Usage php dba_dump <file> <handler> * * Note: configure with --enable-dba */ class dba_reader implements spl::iterator { public $db = NULL; function __construct($file, $handler) { $this->db = dba_open($file, 'r', $handler); } function new_iterator() { return new dba_iter($this); } } class dba_iter implements spl::sequence_assoc { private $obj; private $key = NULL; private $val = NULL; function __construct($obj) { $this->obj = $obj; } function reset() { if ($this->obj->db) { $this->key = dba_firstkey($this->obj->db); } } function elem() { return $this->val; } function next() { $this->key = dba_nextkey($this->obj->db); } function more() { if ($this->obj->db && $this->key !== false) { $this->val = dba_fetch($this->key, $this->obj->db); return true; } else { return false; } } function key() { return $this->key; } } $db = new dba_reader($argv[1], $argv[2]); foreach($db as $key => $val) { echo "'$key' => '$val'\n"; } ?> Index: presentations/slides/php5intro/spl.xml +++ presentations/slides/php5intro/spl.xml <slide> <title>SPL</title> <blurb> SPL is a standard extension by Marcus Börger that allows you to register a set of standard engine level interfaces. </blurb> <example filename="spl.php" title="Database Mapping" /> </slide>

« previous php.pres (#619) next »