Padaco
1.6
Toolbox for interpreting Actigraph accelerometer data collected from children in order to better understand their physical activity and sleep patterns with the intent of reducing obesity and improving their overall health.
|
The class is designed for baseline database development, functionality, and interaction. More...
Public Member Functions | |
virtual | createDBandTables (in obj) |
Abstract method to create a mysql database and tables. The method should be implemented in derived classes according to the database desired. More... | |
function | open (in obj) |
Open the database associated with the derived class. More... | |
function | addTableField (in obj, in tableName, in fieldName, in fieldDefinition) |
Adds a table column to the database associated with the instantiated class. More... | |
function | renameField (in obj, in tableName, in oldFieldName, in newFieldName) |
Rename a table column in the database associated with the instantiated class. More... | |
function | create_DB (in obj) |
Builds a mysql database and sets up permissions to modify for the designated user. More... | |
function | dumpTable2Text (in obj, in tableName) |
Dumps the identified table to a text file using the same name and a '.txt' extension. More... | |
function | dumpTable (in obj, in tableName) |
Performs a system level MySQL dump of the identified table to a file with '.sql' extension. More... | |
function | importTable (in obj, in sqlDumpFile) |
Performs a system level mysqldump call to import the passed sql dump file. More... | |
function | addUser (in obj) |
Adds the user specified in the dbStruct instance variable to the the database (also specified in dbStruct) More... | |
function | createTable (in this, in tableName, in tableStr) |
Creates a database table using the input arguments. More... | |
function | dropTable (in this, in tableName) |
function | selectSome (in this, in tableName, in limit) |
function | query (in this, in queryStr, in varargin) |
function | getColumnNames (in this, in tableName) |
Static Public Member Functions | |
static function | close () |
Closes the current MySQL connection. More... | |
static function | openDB (in dbStruct) |
Helper function for opening the MySQL database using field values provided in dbStruct. More... | |
static function | grantPrivileges (in dbStruct) |
Adds the user specified in the dbStruct instance variable to the the database (also specified in dbStruct)%> More... | |
static function | cellstr2csv (in cellOfKeys) |
Place ',' in between cell string entries for mysql select entry. string = cellstr2csv(cellString) More... | |
static function | cellstr2statcsv (in cellOfFields, in stat) |
Place ',' in between cell string entries for mysql select entry. More... | |
static function | refactorPatstudykey (in table2Refactor, in field2RefactorWith) |
Refactors a table's patstudykey using another field that is listed in the studyinfo_t table (e.g. patid). More... | |
static function | updateDBTableFieldValues (in tableName, in setFieldName, in setFieldValues, in whereFieldName, in whereFieldValues) |
MySQL helper function. Updates fields values for the specified table of the currently open database. This is a wrapper for the the mysql call UPDATE table_name SET field1=new-value1, field2=new-value2 [WHERE Clause]. More... | |
static function | updateTableEntry (in tableName, in fields, in values, in whereStmt) |
MySQL helper function. Updates fields values for the specified table of the currently open database. This is a wrapper for the the mysql call UPDATE table_name SET field1=new-value1, field2=new-value2 [WHERE Clause]. More... | |
static function | deleteTableEntry (in tableName, in whereStmt) |
MySQL helper function. Delete a table entry or entries from the specified table of the current database which match the the where statement provided. This is a wrapper for the the mysql call DELETE FROM table_name WHERE whereStmt. More... | |
static function | query2file (in q, in filename, in optional_delim) |
Writes information in mym query output q to a file. More... | |
static function | query2text (in q, in optional_delim) |
Outputs mym query output statment to the console or string output. More... | |
static function | loadCohortStruct (in struct_filename) |
Retrieves cohort descriptor data as a struct from the .inf filename provided. More... | |
static function | insertRecordFromStruct (in TableName, in insertStruct) |
Inserts a record into a table of the current, open, database using a struct of field name/value pairings. More... | |
static function | updateRecordFromStruct (in tableName, in updateStruct, in whereStmt) |
Updates a table record in the current, open, database using a struct of field name/value pairings. More... | |
static function | loadDatabaseStructFromInf (in inf_filename, in optional_choice) |
Retrieves database access data as a struct from the .inf filename provided. More... | |
static function | exportQuery2File (in query, in filename, in optional_delim) |
Exports the output of a mysql query to a file. More... | |
static function | makeWhereInString (in data, in dataType) |
Public Attributes | |
Property | dbStruct |
Structure containing database accessor fields: More... | |
The class is designed for baseline database development, functionality, and interaction.
function CLASS_database::addTableField | ( | in | obj, |
in | tableName, | ||
in | fieldName, | ||
in | fieldDefinition | ||
) |
Adds a table column to the database associated with the instantiated class.
obj | CLASS_database derivded instance. |
obj | tableName MySQL table to add a column to |
obj | fieldName Name of the column to add to tableName |
obj | fieldDefintion Definition of column being added. |
function CLASS_database::addUser | ( | in | obj | ) |
Adds the user specified in the dbStruct instance variable to the the database (also specified in dbStruct)
obj | Instance of CLASS_database |
|
static |
Place ',' in between cell string entries for mysql select entry. string = cellstr2csv(cellString)
Cell | string of fields to select. |
String |
selectStr = makeSelectKeysString(cellString)
ans = A0001,A0003,A0008
|
static |
Place ',' in between cell string entries for mysql select entry.
Cell | string of fields to select. |
Optional | mysql grouping command (default is 'mean'). |
String |
selectStr = cellstr2statcsv(cellString)
ans = mean(A0001) AS A0001, mean(A0003) AS A0003, mean(A0008) AS A0008
|
static |
Closes the current MySQL connection.
function CLASS_database::create_DB | ( | in | obj | ) |
Builds a mysql database and sets up permissions to modify for the designated user.
obj | Instance of CLASS_database |
|
virtual |
Abstract method to create a mysql database and tables. The method should be implemented in derived classes according to the database desired.
obj | CLASS_database derived instance |
function CLASS_database::createTable | ( | in | this, |
in | tableName, | ||
in | tableStr | ||
) |
Creates a database table using the input arguments.
this | Instance of CLASS_database |
Name | of the table to create (string) |
Column | definitions for the table. |
|
static |
MySQL helper function. Delete a table entry or entries from the specified table of the current database which match the the where statement provided. This is a wrapper for the the mysql call DELETE FROM table_name WHERE whereStmt.
tableName | Name of the table to updated (string) |
whereStmt | The 'where' clause (sans 'where'), which must be included (string) |
function CLASS_database::dropTable | ( | in | this, |
in | tableName | ||
) |
function CLASS_database::dumpTable | ( | in | obj, |
in | tableName | ||
) |
Performs a system level MySQL dump of the identified table to a file with '.sql' extension.
obj | Instance of CLASS_database |
tableName | Name of the table (as a string) which will be dumped as a MySQL file dump. |
function CLASS_database::dumpTable2Text | ( | in | obj, |
in | tableName | ||
) |
Dumps the identified table to a text file using the same name and a '.txt' extension.
obj | Instance of CLASS_database |
tableName | Name of the table (as a string) which will be dumped as a tab-delimited text file with one record per row. |
|
static |
Exports the output of a mysql query to a file.
query | A mysql query (string) |
filename | The filename to save the MySQL results to (string). |
optional_delim | Delimeter to separate each row's results by (optional). For example, ',' would separate using a comma. The default is to use a tab-delimiter (i.e. ''). |
function CLASS_database::getColumnNames | ( | in | this, |
in | tableName | ||
) |
|
static |
Adds the user specified in the dbStruct instance variable to the the database (also specified in dbStruct)%>
dbStruct | A structure containing database accessor fields:
|
function CLASS_database::importTable | ( | in | obj, |
in | sqlDumpFile | ||
) |
Performs a system level mysqldump call to import the passed sql dump file.
obj | Instance of CLASS_database |
sqlDumFile | File name of the mysql dump to import (i.e. a .sql file) |
|
static |
Inserts a record into a table of the current, open, database using a struct of field name/value pairings.
Name | of the table to insert record into (string). |
Struct | of column names and column values to insert into the specified table. |
|
static |
Retrieves cohort descriptor data as a struct from the .inf filename provided.
inf_filename | Full filename (i.e. path included) of either a text file containing cohort descriptor data as tab-delimited entries or an XML formatted file (with .xml extension). |
cohortSstruct | A structure containing file value pairings For example, database accessor fields for a database.inf file would be:
|
|
static |
Retrieves database access data as a struct from the .inf filename provided.
inf_filename | Full filename (i.e. path included) of text file containing database accessor information 'name', 'user', 'password' as tab-delimited entries. |
optional_choice | Optional index that can be provided to return the specified database preference when multiple database entries are present in the supplied inf_filename (integer) |
database_struct | A structure containing database accessor fields:
|
|
static |
function CLASS_database::open | ( | in | obj | ) |
Open the database associated with the derived class.
obj | CLASS_database derivded instance. |
|
static |
Helper function for opening the MySQL database using field values provided in dbStruct.
dbStruct | A structure containing database accessor fields:
|
function CLASS_database::query | ( | in | this, |
in | queryStr, | ||
in | varargin | ||
) |
|
static |
Writes information in mym query output q to a file.
q | The mym query result to be written to file |
filename | Name of the file to store data to (will be created if it does not already exist, or overwrite existing contents |
optional_delim | Optional string delimiter to separate output fields The default is tab delimited (i.e. '') |
|
static |
Outputs mym query output statment to the console or string output.
q | The mym query result to be displayed |
optional_delim | Optional string delimiter to separate output fields The default is tab delimited (i.e. '') |
strout | Stores the output string when provided. |
|
static |
Refactors a table's patstudykey using another field that is listed in the studyinfo_t table (e.g. patid).
obj | Instance of CLASS_database |
table2refactor | Table name whose patstudykey is to be refactored |
fieldToRefactorAgainst | The field which is used as an alternate key into the studyinfo_t which also identifies a uninque record in the table2refactor table. |
function CLASS_database::renameField | ( | in | obj, |
in | tableName, | ||
in | oldFieldName, | ||
in | newFieldName | ||
) |
Rename a table column in the database associated with the instantiated class.
obj | CLASS_database derivded instance. |
obj | tableName MySQL table to add a column to |
obj | oldFieldName Name of the column to change from. |
obj | newFieldName New name to change the column to. |
function CLASS_database::selectSome | ( | in | this, |
in | tableName, | ||
in | limit | ||
) |
|
static |
MySQL helper function. Updates fields values for the specified table of the currently open database. This is a wrapper for the the mysql call UPDATE table_name SET field1=new-value1, field2=new-value2 [WHERE Clause].
tableName | Name of the table to updated (string) |
setFieldName | (string) |
setFieldValues | (array float) |
whereFieldName | (string) |
whereFieldValues | (integer) |
|
static |
Updates a table record in the current, open, database using a struct of field name/value pairings.
Name | of the table to insert record into (string). |
Struct | of column names and column values to update in the table. |
A | where statement (sans "where") to locate the record to update. |
|
static |
MySQL helper function. Updates fields values for the specified table of the currently open database. This is a wrapper for the the mysql call UPDATE table_name SET field1=new-value1, field2=new-value2 [WHERE Clause].
tableName | Name of the table to updated (string) |
fields | Cell of column label(s) (strings) |
values | Cell of column values that correspond to fields' column labeling. |
whereStmt | The 'where' clause (sans 'where'), which must be included (string) |
Property CLASS_database::dbStruct |
Structure containing database accessor fields:
name
Name of the database to use (string) user
Database user (string) password
Password for user
(string)