Component Documentation

DataMgr
Component _DataMgr (Data Manager)

I manage data interactions with the database. I can be used to handle inserts/updates.


methods:

Initialization
init

Major Methods
deleteRecord, deleteRecords, getRecord, getRecords, insertRecord, loadXML, removeColumn, removeTable, runSQL, runSQLArray, saveRecord, saveRelationList, saveSortOrder, setColumn, setNamedFilter, startLogging, stopLogging, truncate, updateRecord, updateRecords

Informational Methods
dbtableexists, getBooleanSqlValue, getDataBase, getDatabaseDriver, getDatabaseProperties, getDatabaseShortString, getDatabaseXml, getDatasource, getDefaultValues, getField, getFieldLengths, getSupportedDatabases, getTableData, getTableProps, getVersion, getXML, isLogging, readableSQL

Support Methods
CreateTables, clean, createTable, getDBFieldList, getFieldList, getFieldSQL_Has, getFieldSelectSQL, getFieldWhereSQL, getFields, getHasFieldSQL, getMaxRowsPrefix, getMaxRowsSuffix, getMaxRowsWhere, getNewSortNum, getOrderBySQL, getPKFields, getPKFromData, getPrimaryKeyField, getPrimaryKeyFieldName, getRecordsSQL, getRelationTypes, getStringTypes, getUpdateableFields, getWhereSQL, insertRecordSQL, insertRecordsSQL, isValidDate, loadTable, logAction, queryparam, setCacheDate, updateRecordSQL, updateRecordsSQL

Deprecated
addColumn

Miscellanious
queryRowToStruct


init

I instantiate and return this object.

Output: suppressed
Parameters:
   datasource: string
   database: string
   username: string
   password: string
   SmartCache: boolean
   SpecialDateType: string

Links:


deleteRecord

I delete the record with the given Primary Key(s).

Output: suppressed
Parameters:
   tablename: string, required (The name of the table from which to delete a record.)
   data: struct, required (A structure indicating the record to delete. A key indicates a field. The structure should have a key for each primary key in the table.)

Links:


deleteRecords

I delete the records with the given data.

Output: suppressed
Parameters:
   tablename: string, required (The name of the table from which to delete a record.)
   data: struct, required (A structure indicating the record to delete. A key indicates a field. The structure should have a key for each primary key in the table.)

Links:


getRecord

I get a recordset based on the primary key value(s) given.

Output: suppressed
Parameters:
   tablename: string, required (The table from which to return a record.)
   data: struct, required (A structure with the data for the desired record. Each key/value indicates a value for the field matching that key. Every primary key field should be included.)
   fieldlist: string (A list of fields to return. If left blank, all fields will be returned.)

getRecords

I get a recordset based on the data given.

Output: suppressed
Parameters:
   tablename: string, required (The table from which to return a record.)
   data: any (A structure with the data for the desired record. Each key/value indicates a value for the field matching that key.)
   orderBy: string
   maxrows: numeric
   fieldlist: string (A list of fields to return. If left blank, all fields will be returned.)
   advsql: struct (A structure of sqlarrays for each area of a query (SELECT,FROM,WHERE,ORDER BY).)
   filters: array
   offset: numeric

Links:


insertRecord

I insert a record into the given table with the provided data and do my best to return the primary key of the inserted record.

Output: suppressed
Parameters:
   tablename: string, required (The table in which to insert data.)
   data: struct, required (A structure with the data for the desired record. Each key/value indicates a value for the field matching that key.)
   OnExists: string (The action to take if a record with the given values exists. Possible values: insert (inserts another record), error (throws an error), update (updates the matching record), skip (performs no action), save (updates only for matching primary key)).)
   fieldlist: string (A list of insertable fields. If left blank, any field can be inserted.)

loadXML

I add tables from XML and optionally create tables/columns as needed (I can also load data to a table upon its creation).

Output: suppressed
Parameters:
   xmldata: string, required (XML data of tables and columns to load into DataMgr. Follows schema: http://www.bryantwebconsulting.com/cfcs/DataMgr.xsd)
   docreate: boolean (I indicate if the table should be created in the database if it doesn't already exist.)
   addcolumns: boolean (I indicate if missing columns should be be created.)

Links:


removeColumn

I remove a column from a table.

Output: suppressed
Parameters:
   tablename: string, required
   field: string, required

Links:


removeTable

I remove a table.

Output: suppressed
Parameters:
   tablename: string, required

Links:


runSQL

I run the given SQL.

Output: suppressed
Parameters:
   sql: string, required

Links:


runSQLArray

I run the given array representing SQL code (structures in the array represent params).

Output: suppressed
Parameters:
   sqlarray: array, required

Links:


saveRecord

I insert or update a record in the given table (update if a matching record is found) with the provided data and return the primary key of the updated record.

Output: suppressed
Parameters:
   tablename: string, required (The table on which to update data.)
   data: struct, required (A structure with the data for the desired record. Each key/value indicates a value for the field matching that key.)
   fieldlist: string (A list of insertable fields. If left blank, any field can be inserted.)

saveRelationList

I save a many-to-many relationship.

Output: suppressed
Parameters:
   tablename: string, required (The table holding the many-to-many relationships.)
   keyfield: string, required (The field holding our key value for relationships.)
   keyvalue: string, required (The value of out primary field.)
   multifield: string, required (The field holding our many relationships for the given key.)
   multilist: string, required (The list of related values for our key.)
   reverse: boolean (Should the reverse of the relationship by run as well (for self-joins)?s.)

Links:


saveSortOrder

I save the sort order of records - putting them in the same order as the list of primary key values.

Output: suppressed
Parameters:
   tablename: string, required (The table on which to update data.)
   sortfield: string, required (The field holding the sort order.)
   sortlist: string, required (The list of primary key field values in sort order.)
   PrecedingRecords: numeric (The number of records preceding those being sorted.)

Links:


setColumn

I set a column in the given table

Output: suppressed
Parameters:
   tablename: string, required (The name of the table to which a column will be added.)
   columnname: string, required (The name of the column to add.)
   CF_Datatype: string (The ColdFusion SQL Datatype of the column.)
   Length: numeric (The ColdFusion SQL Datatype of the column.)
   Default: string (The default value for the column.)
   Special: string (The special behavior for the column.)
   Relation: struct (Relationship information for this column.)
   PrimaryKey: boolean (Indicates whether this column is a primary key.)
   AllowNulls: boolean
   useInMultiRecordsets: boolean

Links:


setNamedFilter


Output: suppressed
Parameters:
   tablename: string, required
   name: string, required
   field: string, required
   operator: string, required

Links:


startLogging

I turn on logging.

Output: suppressed
Parameters:
   logtable: string

Links:


stopLogging

I turn off logging.

Output: suppressed
Parameters:

Links:


truncate

I return the structure with the values truncated to the limit of the fields in the table.

Output: suppressed
Parameters:
   tablename: string, required (The table for which to truncate data.)
   data: struct, required (A structure with the data for the desired record. Each key/value indicates a value for the field matching that key.)

Links:


updateRecord

I update a record in the given table with the provided data and return the primary key of the updated record.

Output: suppressed
Parameters:
   tablename: string, required (The table on which to update data.)
   data: struct, required (A structure with the data for the desired record. Each key/value indicates a value for the field matching that key.)
   advsql: struct (A structure of sqlarrays for each area of a query (SET,WHERE).)

updateRecords


Output: suppressed
Parameters:
   tablename: string, required (The table on which to update data.)
   data_set: struct, required (A structure with the data for the desired record. Each key/value indicates a value for the field matching that key.)
   data_where: struct (A structure with the data for the desired record. Each key/value indicates a value for the field matching that key.)
   filters: array
   fieldlist: string (A list of updateable fields. If left blank, any field can be updated.)
   advsql: struct (A structure of sqlarrays for each area of a query (SET,WHERE).)

Links:


dbtableexists

I indicate whether or not the given table exists in the database

Output: suppressed
Parameters:
   tablename: string, required
   dbtables: string

getBooleanSqlValue


Output: suppressed
Parameters:
   value: string, required

getDataBase

I return the database platform being used.

Output: suppressed
Parameters:

getDatabaseDriver

I return the string that can be found in the driver or JDBC URL for the database platform being used.

Output: suppressed
Parameters:

getDatabaseProperties

I return some properties about this database

Output: suppressed
Parameters:

getDatabaseShortString

I return the string that can be found in the driver or JDBC URL for the database platform being used.

Output: suppressed
Parameters:

getDatabaseXml

I return the XML for the given table or for all tables in the database.

Output: suppressed
Parameters:
   indexes: boolean

getDatasource

I return the datasource used by this Data Manager.

Output: suppressed
Parameters:

getDefaultValues


Output: suppressed
Parameters:
   tablename: string, required

getField

I the field of the given name.

Output: suppressed
Parameters:
   tablename: string, required
   fieldname: string, required

getFieldLengths

I return a structure of the field lengths for fields where this is relevant.

Output: suppressed
Parameters:
   tablename: string, required

getSupportedDatabases

I return the databases supported by this installation of DataMgr.

Output: suppressed
Parameters:

Links:


getTableData

I return information about all of the tables currently loaded into this instance of Data Manager.

Output: suppressed
Parameters:
   tablename: string

getTableProps

I get the internal table representation ready for use by DataMgr.

Output: suppressed
Parameters:
   tablename: string

getVersion


Output: suppressed
Parameters:

getXML

I return the XML for the given table or for all loaded tables if none given.

Output: suppressed
Parameters:
   tablename: string
   indexes: boolean
   showroot: boolean

isLogging


Output: suppressed
Parameters:

readableSQL

I return human-readable SQL from a SQL array (not to be sent to the database).

Output: suppressed
Parameters:
   sqlarray: array, required

CreateTables

I create any tables that I know should exist in the database but don't.

Output: suppressed
Parameters:
   tables: string (I am a list of tables to create. If I am not provided createTables will try to create any table that has been loaded into it but does not exist in the database.)

clean

I return a clean version (stripped of MS-Word characters) of the given structure.

Output: suppressed
Parameters:
   Struct: struct, required

createTable

I take a table (for which the structure has been loaded) and create the table in the database.

Output: suppressed
Parameters:
   tablename: string, required

getDBFieldList

I return a list of fields in the database for the given table.

Output: suppressed
Parameters:
   tablename: string, required

getFieldList

I get a list of fields in DataMgr for the given table.

Output: suppressed
Parameters:
   tablename: string, required

getFieldSQL_Has


Output: suppressed
Parameters:
   tablename: string, required
   field: string, required
   tablealias: string

getFieldSelectSQL


Output: suppressed
Parameters:
   tablename: string, required
   field: string, required
   tablealias: string
   useFieldAlias: boolean

getFieldWhereSQL


Output: suppressed
Parameters:
   tablename: string, required
   field: string, required
   value: string, required
   tablealias: string
   operator: string

getFields

I return an array of all real fields in the given table in DataMgr.

Output: suppressed
Parameters:
   tablename: string, required

getHasFieldSQL


Output: suppressed
Parameters:
   tablename: string, required
   field: string, required
   tablealias: string

getMaxRowsPrefix

I get the SQL before the field list in the select statement to limit the number of rows.

Output: suppressed
Parameters:
   maxrows: numeric, required
   offset: numeric

getMaxRowsSuffix

I get the SQL after the query to limit the number of rows.

Output: suppressed
Parameters:
   maxrows: numeric, required
   offset: numeric

getMaxRowsWhere

I get the SQL in the where statement to limit the number of rows.

Output: suppressed
Parameters:
   maxrows: numeric, required
   offset: numeric

getNewSortNum

I get the value an increment higher than the highest value in the given field to put a record at the end of the sort order.

Output: suppressed
Parameters:
   tablename: string, required
   sortfield: string, required (The field holding the sort order.)

getOrderBySQL


Output: suppressed
Parameters:
   tablename: string, required (The table from which to return a record.)
   data: any (A structure with the data for the desired record. Each key/value indicates a value for the field matching that key.)
   orderBy: string
   maxrows: numeric
   fieldlist: string (A list of fields to return. If left blank, all fields will be returned.)
   function: string (A function to run against the results.)
   advsql: struct (A structure of sqlarrays for each area of a query (SELECT,FROM,WHERE,ORDER BY).)

getPKFields

I return an array of primary key fields.

Output: suppressed
Parameters:
   tablename: string, required

getPKFromData

I get the primary key of the record matching the given data.

Output: suppressed
Parameters:
   tablename: string, required (The table from which to return a primary key.)
   fielddata: struct, required (A structure with the data for the desired record. Each key/value indicates a value for the field matching that key.)

getPrimaryKeyField

I return primary key field for this table.

Output: suppressed
Parameters:
   tablename: string, required (The table from which to return a primary key.)

getPrimaryKeyFieldName

I return primary key field for this table.

Output: suppressed
Parameters:
   tablename: string, required (The table from which to return a primary key.)

getRecordsSQL

I get the SQL to get a recordset based on the data given.

Output: suppressed
Parameters:
   tablename: string, required (The table from which to return a record.)
   data: any (A structure with the data for the desired record. Each key/value indicates a value for the field matching that key.)
   orderBy: string
   maxrows: numeric
   fieldlist: string (A list of fields to return. If left blank, all fields will be returned.)
   function: string (A function to run against the results.)
   advsql: struct (A structure of sqlarrays for each area of a query (SELECT,FROM,WHERE,ORDER BY).)
   filters: array
   offset: numeric

getRelationTypes


Output: suppressed
Parameters:

getStringTypes

I return a list of datypes that hold strings / character values.

Output: suppressed
Parameters:

getUpdateableFields

I return an array of fields that can be updated.

Output: suppressed
Parameters:
   tablename: string, required

getWhereSQL


Output: suppressed
Parameters:
   tablename: string, required (The table from which to return a record.)
   data: struct (A structure with the data for the desired record. Each key/value indicates a value for the field matching that key.)
   advsql: struct (A structure of sqlarrays for each area of a query (SELECT,FROM,WHERE,ORDER BY).)
   filters: array

insertRecordSQL

I insert a record into the given table with the provided data and do my best to return the primary key of the inserted record.

Output: suppressed
Parameters:
   tablename: string, required (The table in which to insert data.)
   data: struct, required (A structure with the data for the desired record. Each key/value indicates a value for the field matching that key.)
   fieldlist: string (A list of insertable fields. If left blank, any field can be inserted.)

insertRecordsSQL


Output: suppressed
Parameters:
   tablename: string, required
   data_set: struct, required (A structure with the data for the desired record. Each key/value indicates a value for the field matching that key.)
   data_where: struct (A structure with the data for the desired record. Each key/value indicates a value for the field matching that key.)
   fieldlist: string (A list of insertable fields. If left blank, any field can be inserted.)
   filters: array

isValidDate


Output: suppressed
Parameters:
   value: string, required

loadTable

I load a table from the database into DataMgr.

Output: suppressed
Parameters:
   tablename: string, required
   ErrorOnNotExists: boolean

logAction

I log an action in the database.

Output: suppressed
Parameters:
   tablename: string, required
   pkval: string
   action: string, required
   data: struct
   sql: any

queryparam

I run the given SQL.

Output: suppressed
Parameters:
   cfsqltype: string
   value: any, required
   maxLength: string
   scale: string
   null: boolean
   list: boolean
   separator: string

setCacheDate


Output: suppressed
Parameters:

updateRecordSQL

I update a record in the given table with the provided data and return the primary key of the updated record.

Output: suppressed
Parameters:
   tablename: string, required (The table on which to update data.)
   data: struct, required (A structure with the data for the desired record. Each key/value indicates a value for the field matching that key.)
   fieldlist: string (A list of updateable fields. If left blank, any field can be updated.)
   advsql: struct (A structure of sqlarrays for each area of a query (SET,WHERE).)

updateRecordsSQL


Output: suppressed
Parameters:
   tablename: string, required (The table on which to update data.)
   data_set: struct (A structure with the data for the desired record. Each key/value indicates a value for the field matching that key.)
   data_where: struct (A structure with the data for the desired record. Each key/value indicates a value for the field matching that key.)
   filters: array
   fieldlist: string (A list of updateable fields. If left blank, any field can be updated.)
   advsql: struct (A structure of sqlarrays for each area of a query (SET,WHERE).)

addColumn

I add a column to the given table (deprecated in favor of setColumn).

Output: suppressed
Parameters:
   tablename: string, required (The name of the table to which a column will be added.)
   columnname: string, required (The name of the column to add.)
   CF_Datatype: string (The ColdFusion SQL Datatype of the column.)
   Length: numeric (The ColdFusion SQL Datatype of the column.)
   Default: string (The default value for the column.)

queryRowToStruct

Makes a row of a query into a structure.

Parameters:
   query: