P-dd

P-dd is a PHP library for creating dynamic relational database documentation, in a number of forms, for an arbitrary database.

Friday, January 05, 2007

Simple ER Diagram Example

Being able to simply create an ER diagram is one of the main reasons I had for starting this project, and with that in mind I figure I should show just how simple it is to do so.

In order to run this you would need to have Graphviz's Neato installed on the web server... though once that's done, this is the sum total of the code you need to use the TestDatasource and produce a full ER diagram like that shown below:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>P-dd: A simple example outputting the default DOT generated diagram using the TestDatasource</title>
</head>
<body>
<?php

require_once( 'include_package.php' );

include_package( 'Datasources' );
include_package( 'DatabaseModel' );
include_package( 'Renderers', true );

$oFactory = new DatabaseFactory( new TestDatasource() );
$oDatabase = $oFactory->ConstructDatabase();

$oImageGenerator = new DotImageGenerator( DotDatabaseRenderer::Render( new DotRendererConfiguration(), $oDatabase ) );
$oImageGenerator->GenerateImageFile( 'Gif', 'ExampleImage.gif' );

echo( HtmlTag::Image( 'ExampleImage.gif', 'Dot generated diagram (using NEATO)') );

?>
</body>
</html>


ExampleImage

Technorati Tags: , , , , , , , , , , , , ,

Labels:

Viewer Screenshot

Whilst the primary purpose of the project is to create a library, rather than an application, there is an application in the P-dd source code.

P-dd Viewer Example screenshot

Able to connect to an Oracle database and produce an interface for navigating through the schema, it should be seen as an example of how easy it is to create applications using the library.

The app consists of a single HTML / CSS / PHP file of around 300 lines (including comments).


Technorati Tags: , , , , , , , , , , , , ,

Labels: