liberty_code / mysql
Library
Requires
- php: ~7 || ~8
- liberty_code/library: ~1.0.0
- liberty_code/sql: ~1.0.0
This package is auto-updated.
Last update: 2025-10-05 21:37:53 UTC
README
Description
Library contains MySQL components, to use SQL components for MySQL data storage.
Requirement
- Script language: PHP: version 7 || 8
Installation
Several ways are possible:
Composer
- Requirement - It requires composer installation. For more information: https://getcomposer.org 
- Command: Move in project root path - cd "<project_root_path>"
- Command: Installation - php composer.phar require liberty_code/mysql ["<version>"]
- Note - Include vendor - If project uses composer, vendor must be included: - require_once('<project_root_path>/vendor/autoload.php');
- Configuration - Installation command allows to add, on composer file "/composer.json", following configuration: - { "require": { "liberty_code/mysql": "<version>" } }
 
Include
- Download - Download following repository.
- Put it on repository root path.
 
- Include source - require_once('<repository_root_path>/include/Include.php');
Usage
MySQL database connection
Connection allows to design MySQL database connection, to connect and request on specific MySQL data storage, from specified configuration.
Elements
- MysqlPdoConnection - Extends PDO connection features, Allows to design a MySQL database connection, using specific PDO standard. 
Example
use liberty_code\sql\database\connection\library\ConstConnection;
use liberty_code\mysql\database\connection\pdo\model\MysqlPdoConnection;
...
// Get connection
$connection = new MysqlPdoConnection(array(
    ConstConnection::TAB_CONFIG_KEY_HOST => 'host',
    ConstConnection::TAB_CONFIG_KEY_DB_NAME => 'db_name'
    ConstConnection::TAB_CONFIG_KEY_CHARSET => 'utf8',
    ConstConnection::TAB_CONFIG_KEY_LOGIN => 'login',
    ConstConnection::TAB_CONFIG_KEY_PASSWORD => 'password'
));
...
// Execute SQL command
$connection->execute('...SQL string command');
...