code & tutorials / php classes / class database home contact sitemap search print view add to favourites recommend site guestbook deutsch/german  

« the very existence of the bicycle is an offense to reason and wisdom. »
(p.j. o'rourke)

 

 

class database connection

with this class it is possible to use one central database connection for all your php applications. that means you only have to define your database-access-data once for all applications. it makes your applications portable and very easy tu adjust in case of database changes! one stept forward in separating logic from db-layer.

i have used this class for all appz of swissroute.com and voegeli.li.

  1. // Include class definition
  2. include_once("class.database.php");
  3.  
  4. // Create Instance of Database class
  5. $database = new Database();
  6.  
  7. // Define SQL Statement
  8. $sql_query = "SELECT * FROM something;";
  9.  
  10. // Use Method->Query() to execute query
  11. $database->Query($sql_query);
  12.  
  13. // "$result" contains the normal mysql-result-object
  14. $result = $database->result;
 
     
  © by marco voegeli, switzerland       357093 visitors total / © & disclaimer up