Thread: New approach
View Single Post
Old 05-09-2008, 03:30 PM   #20 (permalink)
Evulness
The Contributor
 
Evulness's Avatar
 
Join Date: Apr 2008
Location: Tampa, FL
Posts: 65
Thanks: 6
Evulness is on a distinguished road
Default

so i would
Code:
self::$m_pInst = new self(); 
but when i call i would use
Code:
$EvulSys = EvulSession::getInst();
then when ever i need to use the methods from session in sys, i would just call something like...

$EvulSys->set_var("user_name", "Guest");


hows this look...

I am still writing it up on my linux box, but this is what i have so far, haven't tested what i have, but if i'm understanding things right... my next post will be saying it worked :)


Evuldb.php
Code:
<?php
class Evuldb{

private static $EvInst;

//construct & Connect to $host immediatly
function __construct(){
$this->Connect();
}

public static function getInst(){
if (!self::$EvInst) self::$EvInst = new self();
    return self::EvInst;
}

function Connect () { .. connect stuff... }
//other methods etc...
}
?>
EvulSess.php
Code:
<?php
class EvulSession {
private static $EvInst;

//construct class & Start a session immediatly
function __construct(){
    session_start();
}
public static function getInst(){
if (!self::$EvInst) self::$EvInst = new self();
    return self::EvInst;
}
//other methods for session bwlow
}
?>
and Evulsys.php

Code:
<?php
include_once 'Evuldb.php';
include_once 'EvulSess.php';
class EvulSys extends Evuldb {

// declare variables
var $EvulSys;
public static $EvSession;
public static $EvDbase;

//construct & set session & Connect to DB 
function __construct(){
$EvSession = EvulSession::getInst();
$EvulSys = $this->Connect();
}
//do login & other methods
}
?>
oh, i was thinking... i don't HAVE to do that on construct right? i can do that at anytime, in any method? and the instance will only be loaded and used when the method i use, sets the ::getInst()?
__________________
"Knowledge is power. Abuse it."~Evulness
My portfolio: www.evularts.com
Send a message via AIM to Evulness
Evulness is offline  
Reply With Quote