ludoDB

Bookmark and Share

ludoDB - PHP Framework.

LudoDB is a PHP framework especially designed to work well with web pages using Ajax and JSON.

License

Open source, LGPL.

Download

ludoDB can be downloaded from GitHub:

URL: https://github.com/DHTMLGoodies/ludoDB

Updates to the code will be pushed to GitHub continuously.

Click on the zip link to download.

If you have installed Git on your computer, you may also download it using:

git clone https://github.com/DHTMLGoodies/ludoDB ludoDB

Demos/Samples

After downloading ludoDB, you will find examples inside the example folder. Follow the readme files for instructions.

Overview

These are the advantages of using LudoDB:

  • Always get JSON response from the server in the same format.
  • Makes it easier to create and maintain database tables on the serer.
  • Reduces the amount of sql queries in your PHP code.
  • Makes it easy during development to drop and re-create database tables.

In LudoDB, you have three main classes for data:

  • LudoDBModel: Class representing a Model, example: City.
  • LudoDBCollection: Class representing Collection of rows, example: Cities.
  • LudoDBTreeCollection: Class which returns data in tree format.

Example of a City class

<php?
class DemoCity extends LudoDBModel
{
  protected $config = array(
    "table" => "city",
    "sql" => "select * from city where id=?",
    "columns" => array(
      "id" => "int auto_increment not null primary key",
      "name" => array(
        "db" => "varchar(255)",
        "access" => "rw"
      ),
      "state" => array(
        "db" => "int",
        "references" => "state(id) on delete cascade",
        "access" => "rw"
      )
    ),
    "data" => array(
      array("name" => "Stavanger", "state"=> 1),
      array("name" => "Sandnes", "state"=> 1),
      array("name" => "Haugesund", "state"=> 1),
      array("name" => "Bergen", "state"=> 2),
      array("name" => "Houston", "state"=> 3),
      array("name" => "Austin", "state"=> 3),
      array("name" => "San Fransisco", "state"=> 4),
      array("name" => "Los Angeles", "state"=> 4),
      array("name" => "San Diego", "state"=> 4),
    ),
    "indexes" => array("state")

  );
}

This is how you can use it:

<php?
$city = new City(1);
echo $city;

Which will output the properties of City with id 1 in JSON format.

{
  "id" : 1,
  "name": "Stavanger",
  "state": 1

The $config property is used to configure the Database table. It's also possible to use external JSON files for configuration. Just set protected $JSONConfig to true and create a City.json file inside sub folder "JSONConfig".

Example:

{
  "table" : "City",
  "sql": "select * from city where id=?",
  "columns": {
    "id": "int auto_increment not null primary key",
    "name": { "db": "varchar(255)", "access": "rw" },
    "state": {
      "db": "int",
      "references": "state(id) on delete cascade",
      "access": "rw"
    }
  }

More info and instructions are available at https://github.com/DHTMLGoodies/ludoDB.

Comments

No one has commented this - be first!

Post your comment

Don't have an avatar? Create one at Gravatar.com.

Confirmation code:

Go to cbolson.com


About/Contact | A good idea? | Submit a script | Privacy notice
© 2005 - 2024 dhtmlgoodies.com