Class Index | File Index

Classes


Class MysqlDatabaseDriver


Extends BaseSqlDatabaseDriver.
A database driver for mysql. This driver needs the mysql-module installed. Install by using:

  npm install mysql

Defined in: MysqlDatabaseDriver.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
 
dumpDatabaseToFile(file_name)
Store the entire database to a file.
 
Store the structure (not the data!) of this database to a file.
 
escapeValue(value)
Escape the value in such way, that it can be inserted in any sql query without sql injection issues
 
execute(sql, parameters)
Execute an operation on the database.
<private>  
executeRawCommand(tool, parameter_string)
<private>  
 
getTableMeta(table_name)
Retrieve the meta data about all columns in that table.
 
Load the entire database from a file.
 
Load the database structure from a file.
 
query(sql, parameters)
Query the database with a specific sql command for matching rows.
 
Shuts down the database driver and closes the client connection
Methods borrowed from class BaseSqlDatabaseDriver:
addColumn, alterColumn, createTable, createTableRow, deleteTableRows, dropColumn, dropTable, selectTableRows, updateTableRows
Methods borrowed from class Logging:
addTracing, debug, error, fatal, info, log, trace, warn
Class Detail
MysqlDatabaseDriver(name)
Parameters:
{String} name
Name of the mysql database driver instance
{String} options.database Optional, Default: null
Name of the database attached to this driver
{String} options.host
Host of the mysql database server (e.g. "localhost")
{Number} options.port Optional, Default: 3306
Port of the mysql database server
{String} options.user Optional, Default: null
User for the database
{String} options.password Optional, Default: null
Password for the database user
{String} options[command.mysql] Optional, Default: "mysql"
The command line tool to execute raw commands on the database
{String} options[command.mysqldump] Optional, Default: "mysqldump"
The command line tool to execute raw dump commands on the database
Method Detail
{Boolean} dumpDatabaseToFile(file_name)
Store the entire database to a file.
Parameters:
file_name
Returns:
{Boolean} Did an error occur?

{Boolean} dumpStructureToFile(file_name)
Store the structure (not the data!) of this database to a file.
Parameters:
file_name
Returns:
{Boolean} Did an error occur?

{String} escapeValue(value)
Escape the value in such way, that it can be inserted in any sql query without sql injection issues
Parameters:
{Number|String|Boolean} value Optional
Returns:
{String}

{Boolean, Number} execute(sql, parameters)
Execute an operation on the database. The return value is the amount of affected rows or the last insert id.
Parameters:
sql
parameters
Returns:
{Boolean} Did an error occur?
{Number} Affected rows or last insert id

<private> {Boolean, String, String} executeRawCommand(tool, parameter_string)
Parameters:
{String} tool
Either mysql or mysqldump, can be overwritten with the
command.mysql
or
command.mysqldump
options
{String} parameter_string
Parameters to append to the command line call.
Returns:
{Boolean} Did an error occur?
{String} Standard out output
{String} Standard error output

<private> {String} generateColumnDefinitionLineForFieldOptions()
Parameters:
{TableColumnMeta} Optional
field_options
Returns:
{String} A string which can be used in create table or add/drop column sql statements

{Boolean, TableColumnMeta} getTableMeta(table_name)
Retrieve the meta data about all columns in that table.
Parameters:
table_name
Returns:
{Boolean} Did an error occur?
{TableColumnMeta} []

{Boolean} loadDatabaseFromFile(file_name)
Load the entire database from a file.
Parameters:
file_name
Returns:
{Boolean} Did an error occur?

{Boolean} loadStructureFromFile(file_name)
Load the database structure from a file. Wipes the data if the dump contains drop table statements.
Parameters:
file_name
Returns:
{Boolean} Did an error occur?

{Boolean, Object} query(sql, parameters)
Query the database with a specific sql command for matching rows. Those will be returned in an array.
Parameters:
sql
parameters
Returns:
{Boolean} Did an error occur?
{Object} [] The results of the query as array

shutdown()
Shuts down the database driver and closes the client connection

Documentation generated by JsDoc Toolkit 2.3.2 on Fri Jul 01 2011 14:53:37 GMT+0200 (CEST)