2 /** @package verysimple::DB::Reflection */
5 * DBSet is an object representation of foreign key constraint
7 * @package verysimple::DB::Reflection
9 * @copyright 1997-2007 VerySimple, Inc.
10 * @license http://www.gnu.org/licenses/lgpl.html LGPL
17 public $ReferenceTable;
18 public $ReferenceTableName;
19 public $ReferenceKeyColumn;
21 public $KeyColumnNoPrefix;
22 public $ReferenceKeyColumnNoPrefix;
26 * Instantiate new DBConstraint
29 * @param DBTable $table
30 * that is the dependent/child table
32 * array that is result from parsing show create table
34 function __construct($table, $row) {
35 $this->Table
= & $table;
37 $this->Name
= $row [0];
38 $this->KeyColumn
= $row [1];
39 $this->ReferenceTableName
= $row [2];
40 $this->ReferenceKeyColumn
= $row [3];
42 $this->ReferenceTable
= $this->Table
->Schema
->Tables
[$this->ReferenceTableName
];
43 // print "<p><b>" . $this->Table->Name . " constraint references " . $reftable->Name . "</b></p>";
45 $this->NameNoPrefix
= $this->Table
->RemovePrefix ( $this->Name
);
46 $this->KeyColumnNoPrefix
= $this->Table
->RemovePrefix ( $this->KeyColumn
);
47 $this->ReferenceKeyColumnNoPrefix
= $this->ReferenceTable
->RemovePrefix ( $this->ReferenceKeyColumn
);
49 // intelligently decide what a good name for this constraint might be
50 $tmp1 = str_replace ( "__", "_", str_replace ( $this->ReferenceTableName
, "", str_replace ( "_id", "", $this->KeyColumnNoPrefix
) ) . "_" );
51 $tmp2 = $this->ReferenceTableName
;
52 $this->GetterName
= ($tmp1 == "_") ?
$tmp2 : ($tmp1 . $tmp2);