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>
Technorati Tags: software, development, database, diagram, dot, dotty, neato, er, open+source, Oracle, Postgres, MySql, Robert+Baillie, documentationLabels: examples