TDatabase
in package
Database Task manager
Tags
Table of Contents
Methods
- addColumn() : mixed
- Add column
- clearData() : mixed
- Clear table data
- copyData() : mixed
- Copy data from table to table
- copyQuery() : mixed
- Copy data from query to table
- countData() : mixed
- Count data from table
- createTable() : mixed
- Create table
- dropColumn() : mixed
- Drop column
- dropTable() : mixed
- Drop table
- execute() : mixed
- Execute SQL
- exportToFile() : mixed
- Export data to CSV file
- getData() : mixed
- Get RAW Data
- getRowData() : mixed
- Get a row from the table
- importFromFile() : mixed
- Import data from CSV file
- insertData() : mixed
- Insert data
- updateData() : mixed
- Update data
- transform() : mixed
- Transform value according to mapping rules
Methods
addColumn()
Add column
public
static addColumn(mixed $conn, mixed $table, mixed $column, mixed $type, mixed $options) : mixed
Parameters
- $conn : mixed
-
Connection
- $table : mixed
-
Table name
- $column : mixed
-
Column name
- $type : mixed
-
Column type
- $options : mixed
-
Column options
clearData()
Clear table data
public
static clearData(mixed $conn, mixed $table[, mixed $criteria = null ]) : mixed
Parameters
- $conn : mixed
-
Connection
- $table : mixed
-
Table name
- $criteria : mixed = null
-
Filter criteria
copyData()
Copy data from table to table
public
static copyData(mixed $source_conn, mixed $target_conn, mixed $source_table, mixed $target_table, mixed $mapping[, mixed $criteria = null ][, mixed $bulk_inserts = 1 ][, mixed $auto_commit = false ]) : mixed
Parameters
- $source_conn : mixed
-
PDO source connection
- $target_conn : mixed
-
PDO target connection
- $source_table : mixed
-
Source table
- $target_table : mixed
-
Target table
- $mapping : mixed
-
Mapping between fields
- $criteria : mixed = null
-
Filter criteria
- $bulk_inserts : mixed = 1
-
Inserts per time
- $auto_commit : mixed = false
-
Auto commit after x inserts
copyQuery()
Copy data from query to table
public
static copyQuery(mixed $source_conn, mixed $target_conn, mixed $query, mixed $target_table, mixed $mapping[, mixed $prepared_values = null ][, mixed $bulk_inserts = 1 ][, mixed $auto_commit = false ]) : mixed
Parameters
- $source_conn : mixed
-
PDO source connection
- $target_conn : mixed
-
PDO target connection
- $query : mixed
-
SQL Query
- $target_table : mixed
-
Target table
- $mapping : mixed
-
Mapping between fields
- $prepared_values : mixed = null
-
Parameters for SQL Query
- $bulk_inserts : mixed = 1
-
Inserts per time
- $auto_commit : mixed = false
-
Auto commit after x inserts
countData()
Count data from table
public
static countData(mixed $conn, mixed $table[, mixed $criteria = null ]) : mixed
Parameters
- $conn : mixed
-
PDO source connection
- $table : mixed
-
Source table
- $criteria : mixed = null
-
Filter criteria
createTable()
Create table
public
static createTable(mixed $conn, mixed $table, mixed $columns) : mixed
Parameters
- $conn : mixed
-
Connection
- $table : mixed
-
Table name
- $columns : mixed
-
Array of columns
dropColumn()
Drop column
public
static dropColumn(mixed $conn, mixed $table, mixed $column) : mixed
Parameters
- $conn : mixed
-
Connection
- $table : mixed
-
Table name
- $column : mixed
-
Column name
dropTable()
Drop table
public
static dropTable(mixed $conn, mixed $table[, mixed $ifexists = false ]) : mixed
Parameters
- $conn : mixed
-
Connection
- $table : mixed
-
Table name
- $ifexists : mixed = false
-
Drop only if exists
execute()
Execute SQL
public
static execute(mixed $conn, mixed $query) : mixed
Parameters
- $conn : mixed
-
Connection
- $query : mixed
-
SQL
exportToFile()
Export data to CSV file
public
static exportToFile(mixed $source_conn, mixed $source_table, mixed $filename, mixed $mapping[, mixed $criteria = null ][, mixed $separator = ',' ]) : mixed
Parameters
- $source_conn : mixed
-
Source connection
- $source_table : mixed
-
Target table
- $filename : mixed
-
CSV File to import
- $mapping : mixed
-
Mapping between fields
- $criteria : mixed = null
-
Select criteria
- $separator : mixed = ','
-
Columns separator [,]
getData()
Get RAW Data
public
static getData(mixed $conn, mixed $query[, mixed $mapping = null ][, mixed $prepared_values = null ][, Closure|null $action = null ]) : mixed
Parameters
- $conn : mixed
-
Connection
- $query : mixed
-
SQL
- $mapping : mixed = null
-
Mapping between fields
- $prepared_values : mixed = null
-
Parameters for SQL Query
- $action : Closure|null = null
getRowData()
Get a row from the table
public
static getRowData(mixed $conn, mixed $table[, mixed $criteria = null ]) : mixed
Parameters
- $conn : mixed
-
PDO source connection
- $table : mixed
-
Source table
- $criteria : mixed = null
-
Filter criteria
importFromFile()
Import data from CSV file
public
static importFromFile(mixed $filename, mixed $target_conn, mixed $target_table, mixed $mapping[, mixed $separator = ',' ][, mixed $bulk_inserts = 1 ]) : mixed
Parameters
- $filename : mixed
-
CSV File to import
- $target_conn : mixed
-
Target connection
- $target_table : mixed
-
Target table
- $mapping : mixed
-
Mapping between fields
- $separator : mixed = ','
-
Columns separator [,]
- $bulk_inserts : mixed = 1
insertData()
Insert data
public
static insertData(mixed $conn, mixed $table, mixed $values[, mixed $avoid_criteria = null ]) : mixed
Parameters
- $conn : mixed
-
Connection
- $table : mixed
-
Table name
- $values : mixed
-
Array of values
- $avoid_criteria : mixed = null
-
Criteria to avoid insertion
updateData()
Update data
public
static updateData(mixed $conn, mixed $table, mixed $values[, mixed $criteria = null ]) : mixed
Parameters
- $conn : mixed
-
Connection
- $table : mixed
-
Table name
- $values : mixed
-
Array of values
- $criteria : mixed = null
transform()
Transform value according to mapping rules
private
static transform(mixed $row, mixed $map) : mixed
Parameters
- $row : mixed
-
Row values
- $map : mixed
-
Array with mapping instruction