2 /** @package verysimple::DB::Reflection */
5 * import supporting libraries
7 require_once ("DBTable.php");
10 * DBSchema is an object representation of a MySQL Schema/Database
12 * @package verysimple::DB::Reflection
13 * @author Jason Hinkle
14 * @copyright 1997-2007 VerySimple, Inc.
15 * @license http://www.gnu.org/licenses/lgpl.html LGPL
24 * Instantiate new DBSchema
27 * @param DBServer $server
29 * name of schema to parse
31 function __construct($server) {
32 $this->Server
= & $server;
33 $this->Name
= $server->Connection
->DBName
;
34 $this->Tables
= Array ();
38 // print "<pre>"; print_r($this->Tables["ticket"]); die();
42 * Inspects the current schema and loads all tables, keys, etc.
46 private function Load() {
48 $rs = $this->Server
->Connection
->Select ( $sql );
50 // first pass load all the tables. this will initialize each object. we have to
51 // do this first so that we can correctly determine and store "Set" information
52 while ( $row = $this->Server
->Connection
->Next ( $rs ) ) {
53 $this->Tables
[$row ["Tables_in_" . $this->Name
]] = new DBTable ( $this, $row );
56 // now load all the keys and constraints for each table
57 foreach ( $this->Tables
as $table ) {
61 $this->Server
->Connection
->Release ( $rs );
63 $sql = "show table status from `" . $this->Name
. "`";
64 $rs2 = $this->Server
->Connection
->Select ( $sql );
66 // load the extra data
67 while ( $row = $this->Server
->Connection
->Next ( $rs2 ) ) {
68 $this->Tables
[$row ["Name"]]->Engine
= $row ["Engine"];
69 $this->Tables
[$row ["Name"]]->Comment
= $row ["Comment"];
71 $this->Server
->Connection
->Release ( $rs2 );