protected function AnalyzeTableColumn(QDatabaseFieldBase $objField, $objTable) { $objColumn = new QColumn(); $objColumn->Name = $objField->Name; $objColumn->OwnerTable = $objTable; if (substr_count($objField->Name, "-")) { $tableName = $objTable ? " in table " . $objTable->Name : ""; $this->strErrors .= "Invalid column name" . $tableName . ": " . $objField->Name . ". Dashes are not allowed."; return null; } $objColumn->DbType = $objField->Type; $objColumn->VariableType = $this->VariableTypeFromDbType($objColumn->DbType); $objColumn->VariableTypeAsConstant = QType::Constant($objColumn->VariableType); $objColumn->Length = $objField->MaxLength; $objColumn->Default = $objField->Default; $objColumn->PrimaryKey = $objField->PrimaryKey; $objColumn->NotNull = $objField->NotNull; $objColumn->Identity = $objField->Identity; $objColumn->Unique = $objField->Unique; if ($objField->PrimaryKey && $objTable && count($objTable->PrimaryKeyColumnArray) == 1) { $objColumn->Unique = true; } $objColumn->Timestamp = $objField->Timestamp; $objColumn->VariableName = $this->VariableNameFromColumn($objColumn); $objColumn->PropertyName = $this->PropertyNameFromColumn($objColumn); $objColumn->Comment = $objField->Comment; return $objColumn; }
protected function AnalyzeTableColumn(QDatabaseFieldBase $objField, $objTable) { $objColumn = new QColumn(); $objColumn->Name = $objField->Name; $objColumn->DbType = $objField->Type; $objColumn->VariableType = $this->VariableTypeFromDbType($objColumn->DbType); $objColumn->VariableTypeAsConstant = QType::Constant($objColumn->VariableType); $objColumn->Length = $objField->MaxLength; $objColumn->Default = $objField->Default; $objColumn->PrimaryKey = $objField->PrimaryKey; $objColumn->NotNull = $objField->NotNull; $objColumn->Identity = $objField->Identity; $objColumn->Unique = $objField->Unique; if ($objField->PrimaryKey && $objTable && count($objTable->PrimaryKeyColumnArray) == 1) { $objColumn->Unique = true; } $objColumn->Timestamp = $objField->Timestamp; $objColumn->VariableName = $this->VariableNameFromColumn($objColumn); $objColumn->PropertyName = $this->PropertyNameFromColumn($objColumn); return $objColumn; }
protected function AnalyzeTableColumn(QDatabaseFieldBase $objField, $objTable) { $objColumn = new QSqlColumn(); $objColumn->Name = $objField->Name; $objColumn->OwnerTable = $objTable; if (substr_count($objField->Name, "-")) { $tableName = $objTable ? " in table " . $objTable->Name : ""; $this->strErrors .= "Invalid column name" . $tableName . ": " . $objField->Name . ". Dashes are not allowed."; return null; } $objColumn->DbType = $objField->Type; $objColumn->VariableType = $this->VariableTypeFromDbType($objColumn->DbType); $objColumn->VariableTypeAsConstant = QType::Constant($objColumn->VariableType); $objColumn->Length = $objField->MaxLength; $objColumn->Default = $objField->Default; $objColumn->PrimaryKey = $objField->PrimaryKey; $objColumn->NotNull = $objField->NotNull; $objColumn->Identity = $objField->Identity; $objColumn->Unique = $objField->Unique; if ($objField->PrimaryKey && $objTable && count($objTable->PrimaryKeyColumnArray) == 1) { $objColumn->Unique = true; } $objColumn->Timestamp = $objField->Timestamp; $objColumn->VariableName = $this->ModelColumnVariableName($objColumn); $objColumn->PropertyName = $this->ModelColumnPropertyName($objColumn->Name); // separate overrides embedded in the comment // extract options embedded in the comment field if (($strComment = $objField->Comment) && ($pos1 = strpos($strComment, '{')) !== false && ($pos2 = strrpos($strComment, '}', $pos1))) { $strJson = substr($strComment, $pos1, $pos2 - $pos1 + 1); $a = json_decode($strJson, true); if ($a) { $objColumn->Options = $a; $objColumn->Comment = substr($strComment, 0, $pos1) . substr($strComment, $pos2 + 1); // return comment without options if (!empty($a['Timestamp'])) { $objColumn->Timestamp = true; // alternate way to specify that a column is a self-updating timestamp } if ($objColumn->Timestamp && !empty($a['AutoUpdate'])) { $objColumn->AutoUpdate = true; } } else { $objColumn->Comment = $strComment; } } // merge with options found in the design editor, letting editor take precedence $objColumn->Options = $this->objModelConnectorOptions->GetOptions($objTable->ClassName, $objColumn->PropertyName) + $objColumn->Options; return $objColumn; }