Re: green bean question on singleton php5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jan 16, 2008 12:57 PM, julian <correojulian33-php@xxxxxxxx> wrote:
>
>
> Hi,
>
> I am implementing this
[snip!]

    I'm heading out to lunch, so double-check this for errors, but I
rewrote your class.  You'll have to add your fetch handlers and such.

<?
class dbaccess{
  static $db = null;
  static $conn = null;
  static $query = null;
  static $othervar = 33;

  private function self(){
    dbaccess::$conn = new mysqli(HOST,DBNAME,PASS,USERNAME);
    if(mysqli_connect_errno()){
      return False;
    } else {
        return dbaccess::$conn;
    }
  }

  public function query($query){
        dbaccess::$query = mysqli_query(dbaccess::self(),$query);
        return dbaccess::$query;
  }

public static function GetDb(){
  if(dbaccess::$db==null){
  dbaccess::$db= new dbaccess();
  }
  return dbaccess::$db;

  }
}


$db=dbaccess::GetDb();
$db->query(......................); // Your query here.
?>

-- 
</Dan>

Daniel P. Brown
Senior Unix Geek and #1 Rated "Year's Coolest Guy" By Self Since
Nineteen-Seventy-[mumble].

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux