Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
session_db.php
Package: ext-3.1.0.zip [view]
Upload User: dawnssy
Upload Date: 2022-08-06
Package Size: 9345k
Code Size: 1k
Category:
JavaScript
Development Platform:
JavaScript
- <?php
- /**
- * @class SessionDB
- * Fake Database. Stores records in $_SESSION
- */
- class SessionDB {
- public function __construct() {
- if (!isset($_SESSION['pk'])) {
- $_SESSION['pk'] = 10; // <-- start fake pks at 10
- $_SESSION['rs'] = getData(); // <-- populate $_SESSION with data.
- }
- }
- // fake a database pk
- public function pk() {
- return $_SESSION['pk']++;
- }
- // fake a resultset
- public function rs() {
- return $_SESSION['rs'];
- }
- public function insert($rec) {
- array_push($_SESSION['rs'], $rec);
- }
- public function update($idx, $attributes) {
- $_SESSION['rs'][$idx] = $attributes;
- }
- public function destroy($idx) {
- return array_shift(array_splice($_SESSION['rs'], $idx, 1));
- }
- }
- // Sample data.
- function getData() {
- return array(
- array('id' => 1, 'first' => "Fred", 'last' => 'Flintstone', 'email' => 'fred@flintstone.com'),
- array('id' => 2, 'first' => "Wilma", 'last' => 'Flintstone', 'email' => 'wilma@flintstone.com'),
- array('id' => 3, 'first' => "Pebbles", 'last' => 'Flintstone', 'email' => 'pebbles@flintstone.com'),
- array('id' => 4, 'first' => "Barney", 'last' => 'Rubble', 'email' => 'barney@rubble.com'),
- array('id' => 5, 'first' => "Betty", 'last' => 'Rubble', 'email' => 'betty@rubble.com'),
- array('id' => 6, 'first' => "BamBam", 'last' => 'Rubble', 'email' => 'bambam@rubble.com')
- );
- }