Skip to content
Simple, hi-level abstraction layer for database manipulation in PHP
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.


Simple, hi-level abstraction layer for database manipulation in PHP

####PDO-Altitude is a set of two PHP objects, allowing you to easily make lists of items, and read, create, update, delete items from a database table

Full documentation and examples available here (FR & EN):

Altitude provides two PHP objects, made to perform common operations on MySQL5 or SQLite3 databases, in a secure way, without having to write SQL requests by hand. These two objects are:

  • Object Listing : To retreive a list of data from an SQL table, according to a filtering.
  • Object Infos : For "CRUD" operations (Create Read Update Delete) on a single entry of an SQL table.

####It's compatible with MySQL and SQLite, working seamlessly with one or another


Altitude uses PHP's PDO extension to work. So you must ensure of its activation within the php.ini file of your server.

Just copy the two PHP files from this repo's classes/ folder to your project.

Then, Altitude needs at least those 5 constants to work:

define ("HOST", "localhost");				// MySQL server host name
define ("USER", "username");				// SQL user
define ("PASS", "********");				// Password
define ("BASE", "database");				// MySQL database name
define ("DSN",  "mysql:dbname=".BASE.";host=".HOST);
// Or, for SQLite database:
// define("DSN","sqlite:path/to/altitude-example.sqlite");

Finally, include the Altitude classes in your PHP script:


(You may also automatically load these files with an spl_autoload_register() function.)
And you're done!

More documentation and examples available here:

##How to use: quick start


'Listing' is designed to get several entries from a table of the database, using filters, order by, etc.

Here is a small example of simple use. Let's say we've got a table named "users" in our database:

$l = new Listing();
$users = $l->getList("users");

This will print an array of all users in the table, with their informations in a sub-array.

Now let's say we only want users that are older than 70, but still alive, and order them by name:

$l = new Listing();
$l->addFilter("age",   ">", 70);
$l->addFilter("alive", "=",  1);
$users = $l->getList("users", "*", "name");

'Listing' can also automatically retreive joints and decode JSON, can be very flexible with the use of custom SQL requests, and works for both MySQL and SQLite seamlessly.

For more informations, please read full documentation here:


'Infos' is designed to get one particular entry from a table of the database, but also add, update or delete it.

Here is a small example of simple use of getting an item. Let's say we want the user with ID #3 in table "users":

$i = new Infos("users");
$i->loadInfos("id", "3");
$user = $i->getManyInfos();

This will print an array which contains all informations of the user #3.

Now let's update our #3 user's pseudo:

$i = new Infos("users");
$i->loadInfos("id", 3);
$i->setInfo("pseudo", "Jackie");

Note that, to add a user in the table, you just need to ommit the $i->loadInfos() line. If no item loaded, Altitude Infos object will automatically create it (but you'll need to add some mandatory informations, according to your table structure).

And, to delete this user:

$i = new Infos("users");
$i->loadInfos("id", 3);

For more informations, please read full documentation here:

Hope you'll find it useful!!

You can’t perform that action at this time.