public function __construct($objSettingsXml) { parent::__construct($objSettingsXml); // Setup Local Arrays $this->strAssociationTableNameArray = array(); $this->objTableArray = array(); $this->objTypeTableArray = array(); $this->strExcludedTableArray = array(); // Set the DatabaseIndex $this->intDatabaseIndex = QCodeGen::LookupSetting($objSettingsXml, null, 'index', QType::Integer); // Append Suffix/Prefixes $this->strClassPrefix = QCodeGen::LookupSetting($objSettingsXml, 'className', 'prefix'); $this->strClassSuffix = QCodeGen::LookupSetting($objSettingsXml, 'className', 'suffix'); $this->strAssociatedObjectPrefix = QCodeGen::LookupSetting($objSettingsXml, 'associatedObjectName', 'prefix'); $this->strAssociatedObjectSuffix = QCodeGen::LookupSetting($objSettingsXml, 'associatedObjectName', 'suffix'); // Table Type Identifiers $strTypeTableSuffixList = QCodeGen::LookupSetting($objSettingsXml, 'typeTableIdentifier', 'suffix'); $strTypeTableSuffixArray = explode(',', $strTypeTableSuffixList); foreach ($strTypeTableSuffixArray as $strTypeTableSuffix) { $this->strTypeTableSuffixArray[] = trim($strTypeTableSuffix); $this->intTypeTableSuffixLengthArray[] = strlen(trim($strTypeTableSuffix)); } $this->strAssociationTableSuffix = QCodeGen::LookupSetting($objSettingsXml, 'associationTableIdentifier', 'suffix'); $this->intAssociationTableSuffixLength = strlen($this->strAssociationTableSuffix); // Stripping TablePrefixes $this->strStripTablePrefix = QCodeGen::LookupSetting($objSettingsXml, 'stripFromTableName', 'prefix'); $this->intStripTablePrefixLength = strlen($this->strStripTablePrefix); // Exclude/Include Tables $this->strExcludePattern = QCodeGen::LookupSetting($objSettingsXml, 'excludeTables', 'pattern'); $strExcludeList = QCodeGen::LookupSetting($objSettingsXml, 'excludeTables', 'list'); $this->strExcludeListArray = explode(',', $strExcludeList); array_walk($this->strExcludeListArray, 'array_trim'); // Include Patterns $this->strIncludePattern = QCodeGen::LookupSetting($objSettingsXml, 'includeTables', 'pattern'); $strIncludeList = QCodeGen::LookupSetting($objSettingsXml, 'includeTables', 'list'); $this->strIncludeListArray = explode(',', $strIncludeList); array_walk($this->strIncludeListArray, 'array_trim'); // ManualQuery Support $this->blnManualQuerySupport = QCodeGen::LookupSetting($objSettingsXml, 'manualQuery', 'support', QType::Boolean); // Relationship Scripts $this->strRelationships = QCodeGen::LookupSetting($objSettingsXml, 'relationships'); $this->strRelationshipsScriptPath = QCodeGen::LookupSetting($objSettingsXml, 'relationshipsScript', 'filepath'); $this->strRelationshipsScriptFormat = QCodeGen::LookupSetting($objSettingsXml, 'relationshipsScript', 'format'); // Column Comment for MetaControlLabel setting. $this->strCommentMetaControlLabelDelimiter = QCodeGen::LookupSetting($objSettingsXml, 'columnCommentForMetaControl', 'delimiter'); // Check to make sure things that are required are there if (!$this->intDatabaseIndex) { $this->strErrors .= "CodeGen Settings XML Fatal Error: databaseIndex was invalid or not set\r\n"; } // Aggregate RelationshipLinesQcodo and RelationshipLinesSql arrays if ($this->strRelationships) { $strLines = explode("\n", strtolower($this->strRelationships)); if ($strLines) { foreach ($strLines as $strLine) { $strLine = trim($strLine); if ($strLine && strlen($strLine) > 2 && substr($strLine, 0, 2) != '//' && substr($strLine, 0, 2) != '--' && substr($strLine, 0, 1) != '#') { $this->strRelationshipLinesQcodo[$strLine] = $strLine; } } } } if ($this->strRelationshipsScriptPath) { if (!file_exists($this->strRelationshipsScriptPath)) { $this->strErrors .= sprintf("CodeGen Settings XML Fatal Error: relationshipsScript filepath \"%s\" does not exist\r\n", $this->strRelationshipsScriptPath); } else { $strScript = strtolower(trim(file_get_contents($this->strRelationshipsScriptPath))); switch (strtolower($this->strRelationshipsScriptFormat)) { case 'qcodo': case 'qcubed': $strLines = explode("\n", $strScript); if ($strLines) { foreach ($strLines as $strLine) { $strLine = trim($strLine); if ($strLine && strlen($strLine) > 2 && substr($strLine, 0, 2) != '//' && substr($strLine, 0, 2) != '--' && substr($strLine, 0, 1) != '#') { $this->strRelationshipLinesQcodo[$strLine] = $strLine; } } } break; case 'sql': // Separate all commands in the script (separated by ";") $strCommands = explode(';', $strScript); if ($strCommands) { foreach ($strCommands as $strCommand) { $strCommand = trim($strCommand); if ($strCommand) { // Take out all comment lines in the script $strLines = explode("\n", $strCommand); $strCommand = ''; foreach ($strLines as $strLine) { $strLine = trim($strLine); if ($strLine && substr($strLine, 0, 2) != '//' && substr($strLine, 0, 2) != '--' && substr($strLine, 0, 1) != '#') { $strLine = str_replace(' ', ' ', $strLine); $strLine = str_replace(' ', ' ', $strLine); $strLine = str_replace(' ', ' ', $strLine); $strLine = str_replace(' ', ' ', $strLine); $strLine = str_replace(' ', ' ', $strLine); $strLine = str_replace(' ', ' ', $strLine); $strLine = str_replace(' ', ' ', $strLine); $strLine = str_replace(' ', ' ', $strLine); $strLine = str_replace(' ', ' ', $strLine); $strLine = str_replace(' ', ' ', $strLine); $strLine = str_replace(' ', ' ', $strLine); $strLine = str_replace(' ', ' ', $strLine); $strCommand .= $strLine . ' '; } } $strCommand = trim($strCommand); if (strpos($strCommand, 'alter table') === 0 && strpos($strCommand, 'foreign key') !== false) { $this->strRelationshipLinesSql[$strCommand] = $strCommand; } } } } break; default: $this->strErrors .= sprintf("CodeGen Settings XML Fatal Error: relationshipsScript format \"%s\" is invalid (must be either \"qcubed\", \"qcodo\" or \"sql\")\r\n", $this->strRelationshipsScriptFormat); break; } } } if ($this->strErrors) { return; } $this->AnalyzeDatabase(); }
public function __construct($objSettingsXml) { parent::__construct($objSettingsXml); // Lookup Instance-Specific Configuration from the SettingsXml Node $this->strServiceUrl = QCodeGen::LookupSetting($objSettingsXml, null, 'serviceUrl'); }