本文整理汇总了C++中Constraint::GetLocalColumn方法的典型用法代码示例。如果您正苦于以下问题:C++ Constraint::GetLocalColumn方法的具体用法?C++ Constraint::GetLocalColumn怎么用?C++ Constraint::GetLocalColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Constraint
的用法示例。
在下文中一共展示了Constraint::GetLocalColumn方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetConstraints
void TableSettings::GetConstraints(SerializableList& keys, const wxString& localcol)
{
for( SerializableList::iterator it = m_lstKeys.begin();
it != m_lstKeys.end(); ++it ) {
Constraint *c = wxDynamicCast( *it, Constraint );
if( c && ( c->GetLocalColumn() == localcol ) ) keys.Append( *it );
}
}
示例2: GetConstraint
Constraint* TableSettings::GetConstraint(Constraint::constraintType type,const wxString& localcol)
{
for( SerializableList::iterator it = m_lstKeys.begin();
it != m_lstKeys.end(); ++it ) {
Constraint *c = wxDynamicCast( *it, Constraint );
if( c && c->GetType() == type && c->GetLocalColumn() == localcol ) return c;
}
return NULL;
}
示例3: IsPrimaryKey
bool TableSettings::IsPrimaryKey(const wxString& colname)
{
for( SerializableList::iterator it = m_lstKeys.begin();
it != m_lstKeys.end(); ++it ) {
Constraint *c = wxDynamicCast( *it, Constraint );
if( c && ( c->GetType() == Constraint::primaryKey )
&& ( c->GetLocalColumn() == colname ) ) return true;
}
return false;
}
示例4: GetCreateTableSql
wxString MySqlDbAdapter::GetCreateTableSql(Table* tab, bool dropTable)
{
//TODO:SQL:
wxString str = wxT("");
if (dropTable) str = wxString::Format(wxT("SET FOREIGN_KEY_CHECKS = 0;\nDROP TABLE IF EXISTS `%s` ;\nSET FOREIGN_KEY_CHECKS = 1; \n"),tab->GetName().c_str());
str.append(wxString::Format(wxT("CREATE TABLE `%s` (\n"),tab->GetName().c_str()));
SerializableList::compatibility_iterator node = tab->GetFirstChildNode();
while( node ) {
Column* col = NULL;
if( node->GetData()->IsKindOf( CLASSINFO(Column)) ) col = (Column*) node->GetData();
if(col) str.append(wxString::Format(wxT("\t`%s` %s"),col->GetName().c_str(), col->GetType()->ReturnSql().c_str()));
Constraint* constr = wxDynamicCast(node->GetData(),Constraint);
if (constr) {
if (constr->GetType() == Constraint::primaryKey) str.append(wxString::Format(wxT("\tPRIMARY KEY (`%s`) \n"), constr->GetLocalColumn().c_str()));
}
node = node->GetNext();
if (node) {
if (wxDynamicCast(node->GetData(),Column)) str.append(wxT(",\n ")) ;
else if ((constr = wxDynamicCast(node->GetData(),Constraint))) {
if (constr->GetType() == Constraint::primaryKey) str.append(wxT(",\n ")) ;
}
}
//else str.append(wxT("\n ")) ;
}
/* Column* col = tab->GetFristColumn();
while (col) {
str.append(wxString::Format(wxT("\t`%s` %s"),col->getName().c_str(), col->getPType()->ReturnSql().c_str()));
col = wxDynamicCast(col->GetSibbling(),Column);
if (col) str.append(wxT(",\n ")) ;
else str.append(wxT("\n ")) ;
}*/
str.append(wxT("\n) ENGINE=INNODB;\n"));
str.append(wxT("-- -------------------------------------------------------------\n"));
return str;
}
示例5: GetAlterTableConstraintSql
wxString MySqlDbAdapter::GetAlterTableConstraintSql(Table* tab)
{
//TODO:SQL:
wxString str = wxString::Format(wxT("-- ---------- CONSTRAINTS FOR TABLE `%s` \n"),tab->GetName().c_str());
str.append(wxT("-- -------------------------------------------------------------\n"));
wxString prefix = wxString::Format(wxT("ALTER TABLE `%s` "),tab->GetName().c_str());
SerializableList::compatibility_iterator node = tab->GetFirstChildNode();
while( node ) {
Constraint* constr = NULL;
constr = wxDynamicCast(node->GetData(), Constraint);
if (constr) {
if (constr->GetType() == Constraint::foreignKey) {
str.append(prefix + wxString::Format(wxT("ADD CONSTRAINT `%s` FOREIGN KEY (`%s`) REFERENCES `%s`(`%s`) " ), constr->GetName().c_str(), constr->GetLocalColumn().c_str(), constr->GetRefTable().c_str(), constr->GetRefCol().c_str()));
str.append(wxT("ON UPDATE "));
switch(constr->GetOnUpdate()) {
case Constraint::restrict:
str.append(wxT("RESTRICT "));
break;
case Constraint::cascade:
str.append(wxT("CASCADE "));
break;
case Constraint::setNull:
str.append(wxT("SET NULL "));
break;
case Constraint::noAction:
str.append(wxT("NO ACTION "));
break;
}
str.append(wxT("ON DELETE "));
switch(constr->GetOnDelete()) {
case Constraint::restrict:
str.append(wxT("RESTRICT "));
break;
case Constraint::cascade:
str.append(wxT("CASCADE "));
break;
case Constraint::setNull:
str.append(wxT("SET NULL "));
break;
case Constraint::noAction:
str.append(wxT("NO ACTION "));
break;
}
str.append(wxT("; \n"));
}
}//if (constr->GetType() == Constraint::primaryKey) str.append(prefix + wxString::Format(wxT("ADD CONSTRAINT `%s` PRIMARY KEY (`%s`); \n"), constr->GetName().c_str(), constr->GetLocalColumn().c_str()));
node = node->GetNext();
}
str.append(wxT("-- -------------------------------------------------------------\n"));
return str;
}
示例6: GenerateFile
bool ClassGenerateDialog::GenerateFile(Table* pTab, wxTextFile& htmpFile, wxString& hFile, const wxString& classItemName, const wxString& classItemDef, const wxString& classColName, const wxString& classTableName, const wxString& classUtilName)
{
Constraint* pPK = NULL;
int colCount = 0;
int lastEditParam = 0;
SerializableList::compatibility_iterator node = pTab->GetFirstChildNode();
while( node ) {
Constraint* pConstr = wxDynamicCast(node->GetData(),Constraint);
if (pConstr) {
if (pConstr->GetType() == Constraint::primaryKey) pPK = pConstr;
} else colCount++;
node = node->GetNext();
}
Column* pPKCol = NULL;
if (pPK) {
SerializableList::compatibility_iterator node = pTab->GetFirstChildNode();
while( node ) {
Column* pCol = wxDynamicCast(node->GetData(),Column);
if (pCol) {
if (pCol->GetName() == pPK->GetLocalColumn()) pPKCol = pCol;
}
node = node->GetNext();
}
}
if( (pPKCol == NULL) && (pTab->IsView() == false) ) {
m_textLog->AppendText( wxString::Format( _("Table %s has no primary key defined!\n"), pTab->GetName().c_str() ) );
return false;
}
for ( wxString str = htmpFile.GetFirstLine(); !htmpFile.Eof(); str = htmpFile.GetNextLine() ) {
if (str.Contains(wxT("%%classItemGetters%%"))) {
SerializableList::compatibility_iterator node = pTab->GetFirstChildNode();
while( node ) {
Column* pCol = wxDynamicCast(node->GetData(),Column);
if (pCol) {
hFile << wxString::Format(wxT("\tconst %s Get%s() const {"), GetResTypeName(pCol->GetType()->GetUniversalType()).c_str(), pCol->GetName().c_str()) << "\n";
hFile << wxString::Format(wxT("\t\treturn m_%s;"), pCol->GetName().c_str()) << "\n";
hFile << wxString::Format(wxT("\t\t}")) << "\n";
}
node = node->GetNext();
}
} else if (str.Contains(wxT("%%classItemVariables%%"))) {
SerializableList::compatibility_iterator node = pTab->GetFirstChildNode();
while( node ) {
Column* pCol = wxDynamicCast(node->GetData(),Column);
if (pCol) {
hFile << wxString::Format(wxT("\t%s m_%s;"), GetTypeName(pCol->GetType()->GetUniversalType()).c_str(), pCol->GetName().c_str())<< "\n";
}
node = node->GetNext();
}
} else if (str.Contains(wxT("%%classItemLoading%%"))) {
SerializableList::compatibility_iterator node = pTab->GetFirstChildNode();
while( node ) {
Column* pCol = wxDynamicCast(node->GetData(),Column);
if (pCol) {
hFile << wxString::Format(wxT("\t\tm_%s = pResult->%s(wxT(\"%s\"));"),pCol->GetName().c_str(), GetResultFunction(pCol->GetType()->GetUniversalType()).c_str(), pCol->GetName().c_str()) << "\n";
}
node = node->GetNext();
}
} else if (str.Contains(wxT("%%classItemBindings%%"))) {
SerializableList::compatibility_iterator node = pTab->GetFirstChildNode();
while( node ) {
Column* pCol = wxDynamicCast(node->GetData(),Column);
if (pCol) {
hFile << GetDebeaBinding(pCol) << "\n";
}
node = node->GetNext();
}
} else if (str.Contains(wxT("%%classItemAddParameters%%"))) {
bool first = true;
SerializableList::compatibility_iterator node = pTab->GetFirstChildNode();
while( node ) {
Column* pCol = wxDynamicCast(node->GetData(),Column);
if (pCol) {
if( first ) {
hFile << wxString::Format(wxT("\t\t\t%s %s"), GetParamTypeName(pCol->GetType()->GetUniversalType()).c_str(), pCol->GetName().c_str()) << "\n";
first = false;
} else {
hFile << wxString::Format(wxT("\t\t\t,%s %s"), GetParamTypeName(pCol->GetType()->GetUniversalType()).c_str(), pCol->GetName().c_str()) << "\n";
}
}
node = node->GetNext();
}
} else if (str.Contains(wxT("%%classItemSetParams%%"))) {
SerializableList::compatibility_iterator node = pTab->GetFirstChildNode();
while( node ) {
Column* pCol = wxDynamicCast(node->GetData(),Column);
if (pCol ) {
hFile << wxT("\tm_") + pCol->GetName() + wxT(" = ") + pCol->GetName() + wxT(";") << "\n";
}
node = node->GetNext();
}
//.........这里部分代码省略.........