add emptyinsertstm function to table object

creates an empty insert statement for the table fields
This commit is contained in:
Peinthor Rene
2013-03-24 21:20:49 +01:00
parent c4f09765b3
commit 0d601c03f1
2 changed files with 30 additions and 0 deletions

View File

@@ -165,6 +165,29 @@ Table Table::parseSQL(const QString &sSQL)
return Table("");
}
QString Table::emptyInsertStmt() const
{
QString stmt = QString("INSERT INTO `%1` VALUES(").arg(m_name);
QStringList vals;
foreach(FieldPtr f, m_fields) {
if(f->notnull())
{
if(f->isInteger())
vals << "0";
else
vals << "''";
}
else
vals << "NULL";
}
stmt.append(vals.join(","));
stmt.append(");");
return stmt;
}
QString Table::sql() const
{