public function __construct($id = NULL) { parent::__construct(); $this->setTableDefs($this->table_defs); $this->initialize($id); if ($id != NULL) { $this->needs_loading = TRUE; } }
protected function createTable($foo = null) { // First: take care of the obligations to this function call. parent::createTable($foo); // Next: attempt to make a delete trigger if our configuration allows it. if ($this->createTriggers) { $mapName = $this->getFullTableName(); $fromTableName = $this->from->getFullTableName(); $fromPrimary = $this->from->findTableKey(); $toTableName = $this->to->getFullTableName(); $toPrimary = $this->to->findTableKey(); $sql = $this->getSQLConnection(); $mapFromCol = MAP_FROM_COL; $mapToCol = MAP_TO_COL; $fromQuery = <<<QUERY \t\t\t\tCREATE TRIGGER {$mapName}_FromDeleteTrigger \t\t\t\t AFTER DELETE ON {$fromTableName} \t\t\t\t FOR EACH ROW \t\t\t\t DELETE FROM {$mapName} WHERE {$mapFromCol}=OLD.{$fromPrimary} QUERY; $toQuery = <<<QUERY \t\t\t\tCREATE TRIGGER {$mapName}_ToDeleteTrigger \t\t\t\t AFTER DELETE ON {$toTableName} \t\t\t\t FOR EACH ROW \t\t\t\t DELETE FROM {$mapName} WHERE {$mapToCol}=OLD.{$toPrimary} QUERY; dbm_debug("system query", $fromQuery); mysql_query($fromQuery, $sql) or die($fromQuery . "\n\n" . mysql_error()); dbm_debug("system query", $toQuery); mysql_query($toQuery, $sql) or die($toQuery . "\n\n" . mysql_error()); } }