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
25 * Instantiate new DBSchema
28 * @param DBServer $server
30 * name of schema to parse
32 function __construct($server)
34 $this->Server
= & $server;
35 $this->Name
= $server->Connection
->DBName
;
36 $this->Tables
= array ();
40 // print "<pre>"; print_r($this->Tables["ticket"]); die();
44 * Inspects the current schema and loads all tables, keys, etc.
48 private function Load()
51 $rs = $this->Server
->Connection
->Select($sql);
53 // first pass load all the tables. this will initialize each object. we have to
54 // do this first so that we can correctly determine and store "Set" information
55 while ($row = $this->Server
->Connection
->Next($rs)) {
56 $this->Tables
[$row ["Tables_in_" . $this->Name
]] = new DBTable($this, $row);
59 // now load all the keys and constraints for each table
60 foreach ($this->Tables
as $table) {
64 $this->Server
->Connection
->Release($rs);
66 $sql = "show table status from `" . $this->Name
. "`";
67 $rs2 = $this->Server
->Connection
->Select($sql);
69 // load the extra data
70 while ($row = $this->Server
->Connection
->Next($rs2)) {
71 $this->Tables
[$row ["Name"]]->Engine
= $row ["Engine"];
72 $this->Tables
[$row ["Name"]]->Comment
= $row ["Comment"];
75 $this->Server
->Connection
->Release($rs2);