Assemble query strings
from the Artful MySQL Tips List
public string IdName( string name ) {
return name.Contains( " " ) ? "`" + name + "`" : name;
}
public string WorkingQuery( string db, string schema, string table,
string columns, string where, string orderby ) {
return "SELECT " + columns + " FROM " + IdName( schema ) + "." +
IdName( table ) + " " + where + " " + orderby;
}
public string CachedQuery( string db, string schema, string table, string columns,
string where, string orderby, int start, int howmany ) {
return "SELECT " + columns + " FROM " + IdName( schema ) + "." +
IdName( table ) + " " + where + " " + orderby +
" LIMIT " + start.ToString() + "," + howmany.ToString();
}
Return to the Artful MySQL Tips page