home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / wiki / lib / db.php < prev    next >
PHP Script  |  2004-03-08  |  850b  |  37 lines

  1. <?php
  2. // $Id: db.php,v 1.1 2004/01/12 22:14:05 comsubvie Exp $
  3.  
  4. // MySQL database abstractor.  It should be easy to port this to other
  5. //   databases, such as PostgreSQL.
  6. class WikiDB
  7. {
  8.   var $handle;
  9.  
  10.   function WikiDB($persistent, $server, $user, $pass, $database)
  11.   {
  12.     if($persistent)
  13.       { $this->handle = mysql_pconnect($server, $user, $pass); }
  14.     else
  15.       { $this->handle = mysql_connect($server, $user, $pass); }
  16.  
  17.     if($this->handle <= 0)
  18.       { die(LIB_ErrorDatabaseConnect); }
  19.  
  20.     if(mysql_select_db($database, $this->handle) == false)
  21.       { die(LIB_ErrorDatabaseSelect); }
  22.   }
  23.  
  24.   function query($text)
  25.   {
  26.     if(!($qid = mysql_query($text, $this->handle)))
  27.       { die("<strong>".LIB_ErrorDatabaseQuery."</strong><p>$text</p>"); }
  28.     return $qid;
  29.   }
  30.  
  31.   function result($qid)
  32.   {
  33.     return mysql_fetch_row($qid);
  34.   }
  35. }
  36. ?>
  37.