\ReadDb_MySQL

This class will read a database structure into the SmartDatabase. This structure can then be written to XML using the SmartDatabase::WriteXmlSchema() function

-- db structure layout guide --

array(
    "<table name>"=>array(
        "<column name>"=>array(
            "Field"=>"<column name>",
            "Type"=>"<column type>",
            "Null"=>"<YES|NO>",
            "Key"=>"<PRI|UNI|MUL|empty>", //note: PRI=Primary Key, UNI=Unique index, MUL=multiple... seems to mean the same as UNI though
            "Default"=>"<default value|empty>",
            "Extra"=>"<auto_increment|empty>",
            "Collation"=>"<utf8_general_ci|utf8mb4_unicode_ci|latin1_swedish_ci|empty>", //other collations can easily be added if needed
            "IndexType"=>"<UNIQUE|NONUNIQUE|FULLTEXT|empty>", //UNIQUE when Key=PRI,UNI, or MUL. FULLTEXT for fulltext index
        ),
        ...(more columns)...
    ),
    ...(more tables)...
)

--- EXAMPLE ---

function getDbStructure(){
    return array(
        "Template"=>array(
            "TemplateId"=>array(
                "Field"=>"TemplateId",
                "Type"=>"int(1) unsigned",
                "Null"=>"NO",
                "Key"=>"PRI",
                "Default"=>"",
                "Extra"=>"auto_increment",
            "Collation"=>"",
            "IndexType"=>"UNIQUE",
            ),
            "Name"=>array(
                "Field"=>"Name",
                "Type"=>"varchar(255)",
                "Null"=>"NO",
                "Key"=>"UNI",
                "Default"=>"",
                "Extra"=>"",
            "Collation"=>"",
            "IndexType=>"",
            ),
            "Html"=>array(
                "Field"=>"Html",
                "Type"=>"text",
                "Null"=>"YES",
                "Key"=>"",
                "Default"=>"",
                "Extra"=>"",
            "Collation"=>"utf8_general_ci",
            "IndexType"=>"FULLTEXT", //i.e. fulltext index on this column
            ),
        )
);

Reads a database structure properties that the SmartDatabase can use to load/write XML schemas

Summary

Methods
Properties
Constants
Instance()
GetArray()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
__construct()
$instance
N/A

Properties

$instance

$instance : 

Type

Methods

Instance()

Instance() 

GetArray()

GetArray(\DbManager  $dbManager, string  $database = null, string  $table = null, string  $column = null) 

Returns detailed array with all columns for given table in database, or all tables/databases Only works with PMA_MYSQL_INT_VERSION >= 50002! ORIGINAL SOURCE - phpMyAdmin-2.11.11.3 - function PMA_DBI_get_columns_full()

$return = ReadDb_MySQL::Instance()->GetArray($dbManager, "DATABASE_NAME"); //call function from the singleton

//the returned array will contain at least this information
$return = array(
    "TABLE NAME" => array(
        "COLUMN NAME 1" => array(
            "Field"=>"<column name>",
            "Type"=>"<column type>",
            "Null"=>"<YES|NO>",
            "Key"=>"<PRI|UNI|MUL|empty>", //note: PRI=Primary Key, UNI=Unique index, MUL=multiple... seems to mean the same as UNI though
            "Default"=>"<default value|empty>",
            "Extra"=>"<auto_increment|empty>",
            "Collation"=>"<utf8_general_ci|utf8mb4_unicode_ci|latin1_swedish_ci|empty>", //other collations can easily be added if needed
            "IndexType"=>"UNIQUE|NONUNIQUE|FULLTEXT|empty",
    ),
    "COLUMN NAME 2" => array(
        ...etc...
    )
),
);

Parameters

\DbManager $dbManager

the DbManager to use for database communication

string $database

name of database

string $table

name of table to retrieve columns from

string $column

name of specific column

__construct()

__construct()