Skip to content
Snippets Groups Projects
Commit c0f6a28a authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

easy sql-condition

parent 69d97b9c
No related branches found
No related tags found
No related merge requests found
......@@ -377,6 +377,35 @@ SqlCondition.prototype._init = function() {
//init only wraps the clear function to avoid confusion in the constructor (and provide better extensibility)
return this.clear();
}
// some static functions for often used tasks. They are only provided for very simple tasks.
/**
* pField = pValue
* @param {String} pField the database field as "tablename.columnname"; e.g. "ORG.NAME"
* @param {String} pValue the value that shall be set into the prepared statement
* @param {String} [pAlternativeCond=""] Condition that is returned when nothing has been appended.
* @param {String} [pAlias=the current alias] the database alias where the condition shall be executed later (important for column types of preparedStatements)
*
* @return {Array[][][]} Prepared condition with [condition, [[field, type]]]
*/
SqlCondition.equals = function(pField, pValue, pAlternativeCond, pAlias) {
return SqlCondition.begin(pAlias).andPrepare(pField, pValue).build(pAlternativeCond);
}
/**
* pField <> pValue
* @param {String} pField the database field as "tablename.columnname"; e.g. "ORG.NAME"
* @param {String} pValue the value that shall be set into the prepared statement
* @param {String} [pAlternativeCond=""] Condition that is returned when nothing has been appended.
* @param {String} [pAlias=the current alias] the database alias where the condition shall be executed later (important for column types of preparedStatements)
*
* @return {Array[][][]} Prepared condition with [condition, [[field, type]]]
*/
SqlCondition.equalsNot = function(pField, pValue, pAlternativeCond, pAlias) {
return SqlCondition.begin(pAlias).andPrepare(pField, pValue, "# <> ?").build(pAlternativeCond);
}
/**
provides functions for masking sql functions
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment