PHP Class PMA\libraries\Tracker

Mostra file Open project: phpmyadmin/phpmyadmin Class Usage Examples

Protected Properties

Property Type Description
$enabled Whether tracking is ready.

Public Methods

Method Description
activateTracking ( string $dbname, string $tablename, string $version ) : integer Activates tracking of a table.
changeTrackingData ( string $dbname, string $tablename, string $version, string $type, string | array $new_data ) : boolean Changes tracking data of a table.
createDatabaseVersion ( string $dbname, string $version, string $query, string $tracking_set = 'CREATE DATABASE,ALTER DATABASE,DROP DATABASE' ) : integer Creates tracking version of a database (in other words: create a job to track future changes on the database).
createVersion ( string $dbname, string $tablename, string $version, string $tracking_set = '', boolean $is_view = false ) : integer Creates tracking version of a table / view (in other words: create a job to track future changes on the table).
deactivateTracking ( string $dbname, string $tablename, string $version ) : integer Deactivates tracking of a table.
deleteTracking ( string $dbname, string $tablename, string $version = '' ) : integer Removes all tracking data for a table or a version of a table
enable ( ) : void Actually enables tracking. This needs to be done after all underlaying code is initialized.
getLogComment ( ) : string Returns the comment line for the log.
getTrackedData ( string $dbname, string $tablename, string $version ) : mixed Gets the record of a tracking job.
getVersion ( string $dbname, string $tablename, string $statement = null ) : integer Gets the newest version of a tracking job (in other words: gets the HEAD version).
handleQuery ( string $query ) : void Analyzes a given SQL statement and saves tracking data.
isActive ( ) : boolean Gets the on/off value of the Tracker module, starts initialization.
isTracked ( string $dbname, string $tablename ) : boolean Gets the tracking status of a table, is it active or deactive ?
parseQuery ( string $query ) : mixed Parses a query. Gets - statement identifier (UPDATE, ALTER TABLE, .

Protected Methods

Method Description
getTableName ( string $string ) : string Parses the name of a table from a SQL statement substring.

Private Methods

Method Description
_changeTracking ( string $dbname, string $tablename, string $version, integer $new_state ) : integer Changes tracking of a table.
_getTrackingTable ( ) : string Returns the tracking table

Method Details

activateTracking() public static method

Activates tracking of a table.
public static activateTracking ( string $dbname, string $tablename, string $version ) : integer
$dbname string name of database
$tablename string name of table
$version string version
return integer result of SQL query

changeTrackingData() public static method

Changes tracking data of a table.
public static changeTrackingData ( string $dbname, string $tablename, string $version, string $type, string | array $new_data ) : boolean
$dbname string name of database
$tablename string name of table
$version string version
$type string type of data(DDL || DML)
$new_data string | array the new tracking data
return boolean result of change

createDatabaseVersion() public static method

Creates tracking version of a database (in other words: create a job to track future changes on the database).
public static createDatabaseVersion ( string $dbname, string $version, string $query, string $tracking_set = 'CREATE DATABASE,ALTER DATABASE,DROP DATABASE' ) : integer
$dbname string name of database
$version string version
$query string query
$tracking_set string set of tracking statements
return integer result of version insertion

createVersion() public static method

Creates tracking version of a table / view (in other words: create a job to track future changes on the table).
public static createVersion ( string $dbname, string $tablename, string $version, string $tracking_set = '', boolean $is_view = false ) : integer
$dbname string name of database
$tablename string name of table
$version string version
$tracking_set string set of tracking statements
$is_view boolean if table is a view
return integer result of version insertion

deactivateTracking() public static method

Deactivates tracking of a table.
public static deactivateTracking ( string $dbname, string $tablename, string $version ) : integer
$dbname string name of database
$tablename string name of table
$version string version
return integer result of SQL query

deleteTracking() public static method

Removes all tracking data for a table or a version of a table
public static deleteTracking ( string $dbname, string $tablename, string $version = '' ) : integer
$dbname string name of database
$tablename string name of table
$version string version
return integer result of version insertion

enable() public static method

Actually enables tracking. This needs to be done after all underlaying code is initialized.
public static enable ( ) : void
return void

getLogComment() public static method

Returns the comment line for the log.
public static getLogComment ( ) : string
return string Comment, contains date and username

getTableName() protected static method

Parses the name of a table from a SQL statement substring.
protected static getTableName ( string $string ) : string
$string string part of SQL statement
return string the name of table

getTrackedData() public static method

Gets the record of a tracking job.
public static getTrackedData ( string $dbname, string $tablename, string $version ) : mixed
$dbname string name of database
$tablename string name of table
$version string version number
return mixed record DDM log, DDL log, structure snapshot, tracked statements.

getVersion() public static method

Gets the newest version of a tracking job (in other words: gets the HEAD version).
public static getVersion ( string $dbname, string $tablename, string $statement = null ) : integer
$dbname string name of database
$tablename string name of table
$statement string tracked statement
return integer (-1 if no version exists | > 0 if a version exists)

handleQuery() public static method

Analyzes a given SQL statement and saves tracking data.
public static handleQuery ( string $query ) : void
$query string a SQL query
return void

isActive() public static method

Gets the on/off value of the Tracker module, starts initialization.
public static isActive ( ) : boolean
return boolean (true=on|false=off)

isTracked() public static method

Gets the tracking status of a table, is it active or deactive ?
public static isTracked ( string $dbname, string $tablename ) : boolean
$dbname string name of database
$tablename string name of table
return boolean true or false

parseQuery() public static method

..) - type of statement, is it part of DDL or DML ? - tablename
public static parseQuery ( string $query ) : mixed
$query string query
return mixed Array containing identifier, type and tablename.

Property Details

$enabled protected_oe static_oe property

Whether tracking is ready.
protected static $enabled