Recent Posts
None | 9 sec ago
C++ | 28 sec ago
None | 36 sec ago
None | 48 sec ago
Java | 59 sec ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Stig on the 22nd of Nov 2008 08:50:30 AM Download | Raw | Embed | Report
  1. <?php
  2.  
  3. class myClass {
  4.  
  5.  
  6.         var $link, $result;
  7.  
  8.         function db_connect($server, $user, $pass, $database) { // ->db_connect("localhost", "user", "pass", "db");
  9.  
  10.                 if(!$this->link = mysql_connect($server, $user, $pass)) {
  11.                         $this->error("Could not connect: " . mysql_error());
  12.                 }
  13.  
  14.                 if(!mysql_select_db($database, $this->link)) {
  15.                         $this->error("Could not select database: " . mysql_error());
  16.                 }
  17.                
  18.                 return true;
  19.         }
  20.  
  21.         function error($error) {
  22.  
  23.                 $string_error = date("d/m/Y - H:i:s ") . " (" . $_SERVER['REMOTE_ADDR'] . ")\n" . $error . "\n\n";
  24.                 $file = "errors.txt";
  25.                 $file = fopen($file, 'a') or die("Fejl, hændelsen kunne ikke logges!");
  26.                 fwrite($file, $string_error);
  27.                 die("Der er opstået en uventet fejl. Hændelsen er blevet logget og Administrator vil blive informeret.");
  28.         }
  29.  
  30.  
  31.         function getRows() { // while($row = $con->getRows()) { echo $row['id']; }
  32.                 return mysql_fetch_assoc($this->result);
  33.         }
  34.  
  35.         function query($sql) {
  36.  
  37.                 if(!$this->result = mysql_query($sql, $this->link)) {
  38.                         $this->error("mysql_query error: " . mysql_error());
  39.                 }
  40.         }
  41.  
  42.         function getQuery($table, $what="*", $end="") { // ->getQuery("info", "*", "ORDER BY navn ASC");
  43.  
  44.                 $sql = "SELECT $what FROM $table $end";
  45.                 $this->query($sql);
  46.         }
  47.  
  48.         function cntRows() { // echo ->cntRows();
  49.                 return mysql_num_rows($this->result);
  50.         }
  51.  
  52.         function insQuery($table, $column_data) { // ->insert("info", "navn='Navn', adresse='Adresse'");
  53.  
  54.                 $sql = "INSERT INTO $table SET $column_data";
  55.                 $this->query($sql);
  56.         }
  57.  
  58.         function delQuery($table, $where, $is) { // ->delete("info", "id", "1");
  59.  
  60.                 $sql = "DELETE FROM $table WHERE $where = '$is'";
  61.                 $this->query($sql);
  62.         }
  63.  
  64.         function updQuery($table, $what, $with, $where, $is) { // ->updQuery("info", "navn", "Navn", "id", "1");
  65.  
  66.                 $sql = "UPDATE $table SET $what = '$with' WHERE $where = '$is'";
  67.                 $this->query($sql);
  68.         }
  69.  
  70. }
  71. ?>
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: