Datenbank Klasse

Zur zeit arbeite an einem php script das mit EDI Rechnungen verschicken kann. Wärend ich über die Datenbank Anbindung nach gedacht habe, habe ich mich an eine sehr simple jedoch gute implementation erinnert. es handelt sich um ezsql geschrieben von Justin Vincent.  Die Klasse macht es lächerlich einfach, mySQL, Oracle8, SQLite (PHP), in Ihrem PHP-Skript verwenden.

ezSQL Features

  • ezSQL is a widget that makes it ridiculously easy for you to use PHP-PDO, mySQL, Oracle8, InterBase/FireBird, PostgreSQL, SQLite (PHP), SQLite (C++) or MS-SQL database(s) within your PHP/C++ scripts (more db’s coming soon) – now works with codeigniter!
  • Completely free, no restrictions what-so-ever
  • It is one php file that you include at the top of your script. Then, instead of using standard php database functions listed in the php manual, you use a much smaller (and easier) set of ezSQL functions.
  • It automatically caches query results and allows you to use easy to understand functions to manipulate and extract them without causing extra server overhead
  • It has excellent debug functions making it lightning-fast to see what’s going on in your SQL code
  • Most ezSQL functions can return results as Objects, Associative Arrays, or Numerical Arrays
  • It can dramatically decrease development time and in most cases will streamline your code and make things run faster as well as making it very easy to debug and optimise your database queries.
  • Works with Smarty templating language
  • It is a small class and will not add very much overhead to your website.

Hier sind einige Beispiele, wie einfach Datenbanken werden können:

   1: // Get one row from the database and print it out..

   2: $user = $db->get_row("SELECT name,email FROM users WHERE id = 2");


   4: echo $user->name;

   5: echo $user->email;

   1: // Select multiple records from the database and print them out..

   2: $users = $db->get_results("SELECT name, email FROM users");

   3: foreach ( $users as $user )

   4: {

   5:            // Access data using object syntax

   6:            echo $user->name;

   7:            echo $user->email;

   8: }

   1: // Get one variable from the database and print it out..

   2: $var = $db->get_var("SELECT count(*) FROM users");


   4: echo $var;

   1: // Insert into the database

   2: $db->query("INSERT INTO users (id, name, email) VALUES (NULL,'justin','')");


   4: // Update the database

   5: $db->query("UPDATE users SET name = 'Justin' WHERE id = 2)");


          Die komplette Dokumentation findet ihr hier.

        2 Antworten zu “Datenbank Klasse”

        1. Judy sagt:

          You know without a doubt that you put these in the mail
          weeks ago. There was a time where I read
          over 100 books in a six week period. We were
          looking for a „kid horse“ for our 9 year old daughter.

        2. Aw, this was an extremely good post. Taking a few minutes and actual effort to make a superb article… but what can I say… I procrastinate a lot and never manage to get nearly anything done.

        Schreibe einen Kommentar