Namespace DB
The DB object gives developers access to the local data store. One of the more commonly used features, the DB object lets you run queries, retrieve data from the database, and save data back to the system. Any persistent data should be stored with the DB object.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
<static> |
DB.addCustomColumn(object, name, type, options)
Add custom column to specified object.
|
<static> |
DB.deleteObject(objectName, objectName_KEY)
Delete a record from the specified object.
|
<static> |
DB.describe(object)
Returns a Map object describing a database table.
|
<static> |
DB.describe2(object)
Returns a Map object describing a database table.
|
<static> |
DB.describe2AsDictionary(object, options)
describe2AsDictionary has the same function as DB.describe2, except it returns an object using
the following method for key selection:
field name for normal fields (i.e.
|
<static> |
DB.getCount(object, options)
Get a summary count of information from a table.
|
<static> |
DB.getCounts(object, options)
Get summary information from a table.
|
<static> |
DB.getDateString(date)
Converts a JavaScript
Date into a String formatted yyyy-MM-dd HH:mm:ss |
<static> |
DB.getDistinctLeftJoin(objects, options)
Similar to DB.getLeftJoin except this will not return duplicate results
It would then be possible to loop through the results
and retrieve attributes of supporter_event and supporter objects:
|
<static> |
DB.getDistinctObjects(object, options)
Similar to DB.getObjects, except this method will not return duplicate records.
|
<static> |
DB.getDuplicates(object, Options)
|
<static> |
DB.getFieldNames(tableName:)
Return a hashmap containing the fieldnames in the table
|
<static> |
DB.getLeftJoin(objects, options)
Much like DB.getObjects, DB.getLeftJoin returns a group of results.
|
<static> |
DB.getMax(object, maxColumn, options)
Returns the maximum of a series of rows for which all WHERE conditions are met.
|
<static> |
DB.getMin(object, minColumn, options)
Returns the minimum of a series of rows for which all WHERE conditions are met.
|
<static> |
DB.getObject(object, key)
DB.getObject is used to retrieve a single record from the database.
|
<static> |
DB.getObjectDefinition(object)
Equivalent to the mysql commands DESC and SHOW TABLE.
|
<static> |
DB.getObjectId(object)
Get the full object identifier based on the object name that is local to the package.
|
<static> |
DB.getObjects(object, options)
The DB.getObjects method is useful for returning many objects.
|
<static> |
DB.getQuery(queryKey, conditions, options)
Returns the result of a pre-defined query based on the query KEY
|
<static> |
DB.getReport()
|
<static> |
DB.getSum(object, sumColumn, options)
Returns the sum of a series of rows in a table, after WHERE conditions are specified.
|
<static> |
DB.getTagCounts(object, options)
Determines the number of times a particular table is tagged.
|
<static> |
DB.getTaggedObjects(tag, object, options)
|
<static> |
DB.getTags(object, key)
Returns the tags for a database object
|
<static> |
DB.getUniqueKey(objectName, data)
Retrieves a unique key from the database for an object, based on comparing all the values in the data object, one by one
|
<static> |
DB.getValidTags()
Determines the tags used on a particular object.
|
<static> |
DB.hasField(table, field)
Returns whether a field is present in a given table
|
<static> |
DB.insertObjects(targetObject, targetFields, objects, options)
Replicate the MySQL INSERT .
|
<static> |
DB.isSyndicatedCustomField(custom_column_KEY)
DB.isSyndicatedCustomField is useful for organizations using the chapters package.
|
<static> |
DB.objectExists(objectName)
Returns true if the current database contains an object/table of the given name
|
<static> |
DB.saveObject(object, object, key)
Saves/updates a table entry.
|
<static> |
DB.sql(sql)
SQL parser.
|
<static> |
DB.tagObject(tags, objectName, objectKey)
Tag an object with a CSV of values
|
Method Detail
<static>
DB.addCustomColumn(object, name, type, options)
Add custom column to specified object.
- Parameters:
- {String} object
- The name of the object you wish to add a custom column to.
- {String} name
- The name of the custom column. The column name must contain one or more alphanumeric characters or _ and nothing else.
- {String} type
- The type of the custom column ('varchar','text','mediumtext','int','bool','float','date','time','datetime','timestamp','enum','percent', or 'currency').
- {Object} options Optional
- An Object containing the optional parameters of addCustomColumn.
- {String} label Optional
- A more descriptive label.
- {String[]} options Optional
- Options for a field of type 'enum'.
- {boolean} isReserved Optional
- Custom Columns that are set exclusively by the National Organization
- {boolean} exposeToChapters Optional
- Custom Columns created by the National Organization, that are shared down to the chapters
options {...}
<static>
DB.deleteObject(objectName, objectName_KEY)
Delete a record from the specified object. Takes 2 parameters: {String} objectName and {Int or String} objectName_KEY
<? DB.deleteObject('supporter', '1234'); ?>
- Parameters:
- {String} objectName
- name of object to delete from
- {String or Int} objectName_KEY
- id of object to be deleted
- Returns:
- Returns
true
if a value was deleted; otherwise,false
.
- See:
- salsa.deleteObject
<static>
{Array}
DB.describe(object)
Returns a Map object describing a database table.
<?= DB.describe('blog').toJSON() ?>
- Parameters:
- {String} object
- The table to describe.
- Returns:
- See:
- String#escapeJS For details on how map keys are converted to JavaScript-safe variable names.
<static>
{Array}
DB.describe2(object)
Returns a Map object describing a database table. DB.describe2 differs from DB.describe in that it also includes custom fields
associated with the object. When used in conjunction with the Form library, can be used to generate a custom form for editing a record.
<? // describe custom fields for the supporter object print(DB.describe2('supporter').filter(function(field){ return field.isCustom; }).toJSON()); ?>
- Parameters:
- {String} object
- The table to describe.
- Returns:
- See:
- String#escapeJS For details on how map keys are converted to JavaScript-safe variable names.
- DB.describe
<static>
{Object All the fields as a key/value pair}
DB.describe2AsDictionary(object, options)
describe2AsDictionary has the same function as DB.describe2, except it returns an object using
the following method for key selection:
field name for normal fields (i.e. First_Name)
api name for custom fields
data_column for fields in the supporter_custom table
- Parameters:
- {String} object
- Type of object to describe (example: "supporter")
- {Object} options Optional
- Object with options to pass to describe
- {boolean} includeApiNamesOnly Optional
- skip enumerating fields in the supporter_custom table only useful for when object === "supporter"
options {...}
- Returns:
<static>
{Integer}
DB.getCount(object, options)
Get a summary count of information from a table. Returns a count of the number of items in the table, after applying WHERE conditions.
<? var conditions = [ new Condition('supporter_event.Date_Created', '>=', '2008-05-01'), new Condition('supporter_event._Status', '=', 'Attended') ]; var count = DB.getCount('supporter_event', { object: 'supporter_event', conditions: conditions, countColumn: _Status }); // this also works var count2 = DB.getCount({ tableName: 'supporter_event', conditions: conditions, countColumn: _Status }); ?>
- Parameters:
- {String} object
- The table you want the summary information for.
- {Object} options Optional
- An Object containing the optional parameters of the query. Possible
- {Condition[]} conditions Optional
- The WHERE conditions.
- {String} countColumn Optional
- The name of the column on which you want the count run. If not specified, '*' will be assumed. This allows for database optimization: in some databases, COUNT(primary key) is optimized beyond COUNT(*).
options {...}
- Returns:
- The count of rows matching the conditions.
- See:
- Condition
<static>
{Array}
DB.getCounts(object, options)
Get summary information from a table. Returns COUNT, SUM, MAX, MIN for a table.
Equivalent to SQL: SELECT field, count(field), sum(field), min(field), max(field) FROM object GROUP BY field
<? var counts = DB.getCounts('supporter_event', { groupByField: ['_TYPE'], conditions: [ new Condition('supporter_event.Date_Created', '>=', '2008-05-01'), new Condition('supporter_event._Status', '=', 'Attended') ], countColumn: '_Status', orderBy: '_Type DESC', limit: '50,100' }); for each(c in counts) { print(c._Status + ': ' + c.count); } ?>
- Parameters:
- {String} object
- The table you want the summary information for.
- {Object} options Optional
- An Object containing the optional parameters of the query. Possible
- {String[]} groupByField Optional
- The column(s) that by which you want to group.
- {Condition[]} conditions Optional
- The WHERE conditions.
- {String} countColumn Optional
- The column that you want the summary information for. If not specified, '*' will be assumed.
- {String} orderBy Optional
- The column that you want to order the query by. Supports 'orderBy ASC' or 'orderBy DESC'.
- {String} limit Optional
- A String describing the limit and(optional) offset of the number of rows to retrieve in the form "offset, limit" such as "50, 100".
options {...}
- Returns:
- An
Array
of Objects. EachObject
contains the groupBy field by name, and the fieldscount
,sum
,min
, andmax
.
- See:
- Condition
<static>
{String}
DB.getDateString(date)
Converts a JavaScript
Date
into a String
formatted yyyy-MM-dd HH:mm:ss
- Parameters:
- {Date} date
- A JavaScript
Date
object
- Returns:
- A newly formatted
String
<static>
{Array}
DB.getDistinctLeftJoin(objects, options)
Similar to DB.getLeftJoin except this will not return duplicate results
It would then be possible to loop through the results
and retrieve attributes of supporter_event and supporter objects:
<? var conditions = [ new Condition('supporter_event.Date_Created', '>=', '2008-05-01'), new Condition('supporter_event._Status', '=', 'Attended')]; var supporter_events = DB.getDistinctLeftJoin( 'supporter_event, supporter', { conditions: conditions }); <? for each (supporter_event in supporter_events) { ?> Date attended: <?= supporter_event.Date_Created ?><br /> First name: <?= supporter_event.First_Name ?><br /> Last name: <?= supporter_event.Last_Name ?><br /> Email: <?= supporter_event.Email ?><br /> <? } ?>
- Parameters:
- {String} objects
- Comma separated list of the tables to query. For better control of the joins,
you can replace the comma between two tables with a parenthesized ON or USING expression. The objects parameter in the above example can be
rewritten as
'supporter_event(supporter_KEY)supporter'
or as'supporter_event(supporter_event.supporter_KEY=supporter.supporter_KEY)supporter'
. - {Object} options Optional
- An Object containing the optional parameters of the query.
- {Condition[]} conditions Optional
- A Condition array to limit the objects returned.
- {String[]} orderBy Optional
- An array of Strings of field names by which the results will be ordered.
- {String} limit Optional
- A String describing the offset and limit of the number of rows to retrieve in the form 'offset, limit' such as '50, 100'.
- {String[]} includes Optional
- A String array of fields to include in returned objects. Defaults to all. These parameters may also be passed as individual arguments in the order specified here.
options {...}
- Returns:
- The number of records specified by limit if specified; otherwise the first 500 records matching the query. Note that the 500 limit is imposed by the system, and is the maximum number of records returned. If you need to get the 501st record, or any data set larger than the upper limit, you will needed to use a pagination system, using getCount(s), limit and offset.
- See:
- Condition
<static>
{Array}
DB.getDistinctObjects(object, options)
Similar to DB.getObjects, except this method will not return duplicate records.
var supporters = DB.getDistinctObjects('supporter', { conditions: [new Condition('First_Name', '=', 'Chris')], orderBy: ['Date_Created DESC'], limit: '50,100', includes: ['First_Name', 'Last_Name', 'Email'] } );
- Parameters:
- {String} object
- The name of the table you wish to query.
- {Object} options Optional
- An Object containing the optional parameters of the query.
- {Condition[]} conditions Optional
- A Condition array to limit the objects returned.
- {String[]} orderBy Optional
- An array of Strings of field names by which the results will be ordered.
- {String} limit Optional
- A String describing the offset and limit of the number of rows to retrieve in the form 'offset, limit' such as '50, 100'
- {String[]} includes Optional
- A String array of fields to include in returned objects. Defaults to all. These parameters may also be passed as individual arguments in the order specified here.
options {...}
- Returns:
- The number of records specified by limit if specified; otherwise the first 500 records matching the query. Note that the 500 limit is imposed by the system, and is the maximum number of records returned. If you need to get the 501st record, or any data set larger than the upper limit, you will needed to use a pagination system, using getCount(s), limit and offset.
- See:
- Condition
<static>
{Array}
DB.getDuplicates(object, Options)
- Returns:
- See:
- Condition
<static>
DB.getFieldNames(tableName:)
Return a hashmap containing the fieldnames in the table
- Parameters:
- {String} tableName:
- the name of the table to retrieve fieldnames for
<static>
{Array}
DB.getLeftJoin(objects, options)
Much like DB.getObjects, DB.getLeftJoin returns a group of results.
In this case, the results will be a combination of two or more
objects joined by object keys. DB.getLeftJoin is analagous to doing
a left join between two or more tables in SQL. In this example, we
will get all supporter information for supporters who attended events
since May 1st, 2008.
It would then be possible to loop through the results
and retrieve attributes of supporter_event and supporter objects:
<? var conditions = [ new Condition('supporter_event.Date_Created', '>=', '2008-05-01'), new Condition('supporter_event._Status', '=', 'Attended')]; var supporter_events = DB.getLeftJoin( 'supporter_event, supporter', { conditions: conditions }); <? for each (supporter_event in supporter_events) { ?> Date attended: <?= supporter_event.Date_Created ?><br /> First name: <?= supporter_event.First_Name ?><br /> Last name: <?= supporter_event.Last_Name ?><br /> Email: <?= supporter_event.Email ?><br /> <? } ?>
- Parameters:
- {String} objects
- Comma separated list of the tables to query. For better control of the joins,
you can replace the comma between two tables with a parenthesized ON or USING expression. The objects parameter in the above example can be
rewritten as
'supporter_event(supporter_KEY)supporter'
or as'supporter_event(supporter_event.supporter_KEY=supporter.supporter_KEY)supporter'
. - {Object} options Optional
- An Object containing the optional parameters of the query.
- {Condition[]} conditions Optional
- A Condition array to limit the objects returned.
- {String[]} orderBy Optional
- An array of Strings of field names by which the results will be ordered.
- {String} limit Optional
- A String describing the offset and limit of the number of rows to retrieve in the form 'offset, limit' such as '50, 100'.
- {String[]} includes Optional
- A String array of fields to include in returned objects. Defaults to all. These parameters may also be passed as individual arguments in the order specified here.
options {...}
- Returns:
- The number of records specified by limit if specified; otherwise the first 500 records matching the query. Note that the 500 limit is imposed by the system, and is the maximum number of records returned. If you need to get the 501st record, or any data set larger than the upper limit, you will needed to use a pagination system, using getCount(s), limit and offset.
- See:
- Condition
<static>
{Number}
DB.getMax(object, maxColumn, options)
Returns the maximum of a series of rows for which all WHERE conditions are met. Equivalent to SQL: max(<column>)
- Parameters:
- {String} object
- The table for which you want the summary information.
- {String} maxColumn
- The name of the column of which you want the maximum value.
- {Object} options Optional
- An Object containing the optional parameters of the query.
- {Condition[]} conditions Optional
- The WHERE conditions. Set to 'null' if no conditions are required. var conditions = [ new Condition('supporter_event.Date_Created', '>=', '2008-05-01'), new Condition('supporter_event._Status', '=', 'Attended') ]; These parameters may also be passed as individual arguments in the order specified here.
options {...}
- Returns:
- The maximum value.
- See:
- Condition
<static>
{Number}
DB.getMin(object, minColumn, options)
Returns the minimum of a series of rows for which all WHERE conditions are met. Equivalent to SQL: min(<column>)
- Parameters:
- {String} object
- The table for which you want the summary information.
- {String} minColumn
- The name of the column of which you want the minimum value.
- {Object} options Optional
- An Object containing the optional parameters of the query.
- {Condition[]} conditions Optional
- The WHERE conditions. Set to 'null' if no conditions are required. var conditions = [ new Condition('supporter_event.Date_Created', '>=', '2008-05-01'), new Condition('supporter_event._Status', '=', 'Attended') ]; These parameters may also be passed as individual arguments in the order specified here.
options {...}
- Returns:
- The minumum value.
- See:
- Condition
<static>
DB.getObject(object, key)
DB.getObject is used to retrieve a single record from the database.
var supporter = DB.getObject('supporter', '1234');
- Parameters:
- {String} object
- The name of the table to query.
- {String|Integer} key Optional
- The key of the object to retrieve.
- Returns:
- An associative array with fields based on the name of the items in that table.
If no match is found,
{ length: 0 }
is returned
<static>
{Object}
DB.getObjectDefinition(object)
Equivalent to the mysql commands DESC and SHOW TABLE.
- Parameters:
- object
- {String} the name of the table to describe
- Returns:
- An
Object
containing the columnname
,type
,length
, andindex
for a table.
<static>
{String}
DB.getObjectId(object)
Get the full object identifier based on the object name that is local to the package. This method
is most useful in cases where a package has its default database set to something other than "salsa".
In the following example, the default database is "salsa.web"
<? print(DB.getObjectId('forum')); // salsa.web.forum ?>
- Parameters:
- {String} object
- Name of the table for which to get the full id
- Returns:
- The Object ID
<static>
{Array}
DB.getObjects(object, options)
The DB.getObjects method is useful for returning many objects. It
requires an objectName. Other parameters are optional and limit
the set of results to be returned. In its simplest form, DB.getObjects
will return an array all of the objects available.
var supporters = DB.getObjects('supporter', { conditions: [new Condition('First_Name', '=', 'Chris')], orderBy: ['Date_Created DESC'], limit: '50,100', includes: ['First_Name', 'Last_Name', 'Email'] } );
- Parameters:
- {String} object
- The name of the table you wish to query.
- {Object} options Optional
- An Object containing the optional parameters of the query.
- {Condition[]} conditions Optional
- A Condition array to limit the objects returned.
- {String[]} orderBy Optional
- An array of Strings of field names by which the results will be ordered.
- {String} limit Optional
- A String describing the offset and limit of the number of rows to retrieve in the form 'offset, limit' such as '50, 100'
- {String[]} includes Optional
- A String array of fields to include in returned objects. Defaults to all. These parameters may also be passed as individual arguments in the order specified here.
options {...}
- Returns:
- The number of records specified by limit if specified; otherwise the first 500 records matching the query. Note that the 500 limit is imposed by the system, and is the maximum number of records returned. If you need to get the 501st record, or any data set larger than the upper limit, you will needed to use a pagination system, using getCount(s), limit and offset.
- See:
- Condition
<static>
DB.getQuery(queryKey, conditions, options)
Returns the result of a pre-defined query based on the query KEY
<? var conditions = [ new Condition('supporter_event.Date_Created', '>=', '2008-05-01'), new Condition('supporter_event._Status', '=', 'Attended') ]; ?>
- Parameters:
- {Number} queryKey
- The query KEY
- {Conditions[]} conditions
- The WHERE conditions
- {Object} options Optional
- An Object containing the optional parameters for the query.
- {String[]} orderBy Optional
- An array of Strings of field names by which the results will be ordered.
- {String} limit Optional
- A String describing the limit and offset of the number of rows to retrieve in the form 'offset, limit' such as '50, 100'.
- {String[]} includes Optional
- A String array of fields to include in returned objects. Defaults to all. *
options {...}
<static>
{Array}
DB.getReport()
- Parameters:
- {Object}
- Returns:
<static>
{Integer}
DB.getSum(object, sumColumn, options)
Returns the sum of a series of rows in a table, after WHERE conditions are specified.
- Parameters:
- {String} object
- The table for which you want the summary information.
- {String} sumColumn
- The name of the column of which you want the sum total.
- {Object} options Optional
- An Object containing the optional parameters of the query.
- {Condition[]} conditions Optional
- The WHERE conditions. Set to 'null' if no conditions are required. var conditions = [ new Condition('supporter_event.Date_Created', '>=', '2008-05-01'), new Condition('supporter_event._Status', '=', 'Attended') ];
options {...}
- Returns:
- The resulting sum.
- See:
- Condition
<static>
{Array}
DB.getTagCounts(object, options)
Determines the number of times a particular table is tagged.
<? var topTags = DB.getTagCounts('topic', { limit: 10, // get 10 tags orderBy: 'tag DESC' // ordered by tag name }); for (var i = 0, l = topTags.length; i < l; i++) { print(topTags[i].tag + '<br/>'); } ?>
- Parameters:
- {String} object
- The name of the table to query.
- {Object} options Optional
- An Object containing optional parameters for the function.
- Returns:
- An
Array
of objects, one for each tag, with the following properties:tag
label
prefix
count
<static>
{Array}
DB.getTaggedObjects(tag, object, options)
<? var donated_supporters = DB.getTaggedObjects('donated', 'supporter', { conditions: [new Condition('Zip', '=', '94040')], orderBy: 'Date_Created DESC', limit: '50, 100' includes: ['Email', 'First_Name'] }); ?>
- Parameters:
- {String} tag
- The desired tag
- {String} object
- The type of object to retrieve
- {Object} options Optional
- An Object containing the optional parameters of the query. Possible
- {Condition[]} conditions Optional
- The WHERE conditions.
- {String} countColumn Optional
- The column that you want the summary information for. If not specified, '*' will be assumed.
- {String} orderBy Optional
- The column that you want to order the query by. Supports 'orderBy ASC' or 'orderBy DESC'.
- {String} limit Optional
- A String describing the limit and(optional) offset of the number of rows to retrieve in the form "offset, limit" such as "50, 100".
- {String[]} includes Optional
- A String array of fields to include in returned objects. Defaults to all.
options {...}
- Returns:
- An
Array
of tagged objects. If no objects are found, returns an emptyArray
.
- See:
- Condition
<static>
{Array}
DB.getTags(object, key)
Returns the tags for a database object
<? var tags = DB.getTags('action', action.action_KEY); if (tags.length > 0) { ?> <input type="hidden" name="tag" id="tag" value="<?= tags.join(',') ?>"> <? } ?>
- Returns:
- An
Array
of Objects containing the tag, prefix, and label.
<static>
DB.getUniqueKey(objectName, data)
Retrieves a unique key from the database for an object, based on comparing all the values in the data object, one by one
- Parameters:
- objectName
- data
<static>
DB.getValidTags()
Determines the tags used on a particular object. Like getTagCounts but
will not return the exact count. This will generally return more quickly
than getTagCounts if you do not need the exact totals.
<? // get all the tags used on the supporter record to seed an autocompletion widget var autocomplete_data = DB.getValidTags('supporter'); ?> <script> jQuery('#my-autocomplete-input') .autocomplete( <?=autocomplete_data.toJSON()?>, { matchContains: true }); </script>
<static>
DB.hasField(table, field)
Returns whether a field is present in a given table
<static>
DB.insertObjects(targetObject, targetFields, objects, options)
Replicate the MySQL INSERT ... SELECT functionality. Allows bulk insertion of data from one object to another.
The insert version of DB.getObjects. Returns the primary key of the just inserted data.
<? var conditions = [ new Condition('supporter_event.Date_Created', '>=', '2008-05-01'), new Condition('supporter_event._Status', '=', 'Attended') ]; ?>
- Parameters:
- {String} targetObject
- Table that you want to insert data into.
- {Array} targetFields
- Fields that you want to copy.
- {String} objects
- Comma seperated list of tables.
- {Object} options Optional
- An Object containing the optional parameters of the query. Possible
- {Condition[]} conditions Optional
- A Condition array to limit the objects returned. (AKA The WHERE conditions.)
- {String[]} orderBy Optional
- An array of Strings of field names by which the results will be ordered.
- {String} limit Optional
- A String describing the limit and offset of the number of rows to retrieve in the form 'offset, limit' such as '50, 100'.
- {String[]} includes Optional
- A String array of fields to include in returned objects. Defaults to all.
options {...}
<static>
{boolean}
DB.isSyndicatedCustomField(custom_column_KEY)
DB.isSyndicatedCustomField is useful for organizations using the chapters package. Syndicated custom fields
are generated by parent chapters and are read-only.
- Parameters:
- {int} custom_column_KEY
- The key of the custom field.
- Returns:
- A boolean indicating whether or not the specified custom key is syndicated.
<static>
DB.objectExists(objectName)
Returns true if the current database contains an object/table of the given name
- Parameters:
- objectName
<static>
{Integer}
DB.saveObject(object, object, key)
Saves/updates a table entry.
<? var mySupporter = { Email: 'username@domain.com', First_Name: 'Chris', Last_Name: 'L', }; DB.saveObject('supporter', mySupporter); ?>
- Parameters:
- {String} object
- The name of the table to modify
- {Object} object
- An Object containing the fieldnames to modify as keys
- {Integer} key Optional
- If provided, the key of the object to update. Otherwise, a new object will be created.
- Returns:
- The key of the object that was just saved.
<static>
{DB.sqlHandler}
DB.sql(sql)
SQL parser. Given a valid SQL statement, will create a DB.sqlHandler object. Currently, DB.sql is the only way to use OR conditions in your queries.
<? var statement = "SELECT tag from tag_data LEFT JOIN tag USING (tag_KEY) LEFT JOIN database_table USING (database_table_KEY)"; var handler = DB.sql(statement); handler = handler.include("table_name", "tag.prefix") .filter(new Condition("table_name", "like", "blog_entry")) .limit(10) .sort("count(tag_KEY) DESC"); var results = handler.execute(); ?>
- Parameters:
- {String} sql
- the SQL statement
- Returns:
- {DB.sqlHandler} parser the DB.sqlHandler object. Can be used chained
- See:
- DB.sqlHandler
<static>
DB.tagObject(tags, objectName, objectKey)
Tag an object with a CSV of values
<? DB.tagObject('myTag1, myTag2', 'report', 44); ?>
- Parameters:
- {String} tags
- a CSV of tags to save to object
- {String} objectName
- the object you wish to tag
- {String or int} objectKey
- the key of the object you wish to tag