class \mpf\datasources\sql\PDOConnection

class \mpf\datasources\sql\PDOConnection

-no description found-

Attributes
private static array $_instances = {"40cd750bba9870f18aada2478b24840a":{"dns":"mysql:dbname=mpfframework;host=localhost","username":"mirel","password":"xaCbsV8o","driver_options":{"3":2},"loggers":["mpf\\loggers\\InlineCliLogger","mpf\\loggers\\EmailLogger"]}}

-no description found-

private mixed $tableColumns = []

-no description found-

public string $dns

Used to create a new connection

public string $username

Used to create a new connection

public string $password

Used to create a new connection

public string[] $driver_options = []

Extra PDO options.

public string[] $loggers = ["mpf\\loggers\\NullLogger"]

ClassNames and options for every Log object to be used;

private \mpf\loggers\Logger[] $loggersInstances = []

List of all instantiated log classes

Methods

public mixed __construct (string $options = [])

  • $options

    -no description found-

-no description found-

public static \mpf\datasources\sql\PDOConnection get (array $options = [])

  • $options

    -no description found-

-no description found-

public array queryAssoc (string $statement, array $params = [])

  • $statement

    -no description found-

  • $params

    -no description found-

Select rows from table and return them as an associative array;

public array queryClass (string $statement, string $classname, array $params = [], array $ctorargs = [])

  • $statement

    -no description found-

  • $classname

    -no description found-

  • $params

    -no description found-

  • $ctorargs

    -no description found-

Calls PDO query with PDO::FETCH_CLASS option; @link http://ro1.php.net/pdo.query

public int execQuery (string $statement, array $params = [])

  • $statement

    -no description found-

  • $params

    -no description found-

Executes a statement and returns the number of affected rows.

public object queryInto (string $statement, object $object, array $params = [])

  • $statement

    -no description found-

  • $object

    Instantiated object that will have attributes updated

  • $params

    Statement parameters

Calls PDO query with PDO::FETCH_INTO object; @link http://ro1.php.net/pdo.query

public string getTablePk (string $tableName)

  • $tableName

    -no description found-

Get column used as primary key.

public array getTableColumns (string $tableName)

  • $tableName

    -no description found-

Return a list of details about table columns;

public string[] getColumnOptions (string $tableName, string $columnName)

  • $tableName

    -no description found-

  • $columnName

    -no description found-

If column exists in table and it's enum or set it will return all available options. If column exists but it's another type, it will return NULL. If the column doesn't exist it will trow an Exception;

public string getColumnType (string $tableName, string $columnName)

  • $tableName

    -no description found-

  • $columnName

    -no description found-

Returns column type.

public string getColumnDefaultValue (string $tableName, string $columnName)

  • $tableName

    -no description found-

  • $columnName

    -no description found-

Returns default value for selected column or NULL if there is no default;

public bool getColumnCanBeNull (string $tableName, string $columnName)

  • $tableName

    -no description found-

  • $columnName

    -no description found-

Return true or false depending if column can be null or not.

public \mpf\datasources\sql\SqlCommand table (string $tableName)

  • $tableName

    -no description found-

Returns a query builder for selected table

public bool tableExists (mixed $tableName)

  • $tableName

    -no description found-

Check if selected table exists.

protected null init (array $config)

  • $config

    -no description found-

Init logs for current component;

public mixed addLogger (\mpf\loggers\Logger $logger)

  • $logger

    An insantiated object for selected engine;

Add a new logging engine; Usage example:

$this->addLogger(MyCustomLogger::get());

public mixed alert (string $message, array $context = [])

  • $message

    -no description found-

  • $context

    -no description found-

Log alert messages!

public mixed critical (string $message, array $context = [])

  • $message

    -no description found-

  • $context

    -no description found-

Log critical messages!

public mixed debug (string $message, array $context = [])

  • $message

    -no description found-

  • $context

    -no description found-

Log debug messages;

public mixed emergency (string $message, array $context = [])

  • $message

    -no description found-

  • $context

    -no description found-

Log emergency messages;

public mixed error (string $message, array $context = [])

  • $message

    -no description found-

  • $context

    -no description found-

Log error messages;

public mixed info (string $message, array $context = [])

  • $message

    -no description found-

  • $context

    -no description found-

Log info messages;

public mixed log (int $level, string $message, array $context = [])

  • $level

    -no description found-

  • $message

    -no description found-

  • $context

    -no description found-

Log messages;

public mixed notice (string $message, array $context = [])

  • $message

    -no description found-

  • $context

    -no description found-

Log notice messages;

public mixed warning (string $message, array $context = [])

  • $message

    -no description found-

  • $context

    -no description found-

Log warning messages

public mixed collectLogs (int $max = 300, int $level = null)

  • $max

    Max number of logs

  • $level

    Max level;

Return list of logs from all Logger objects; Some logger engines may not return any logs per instance, instead store them all and have an extra method to return all;