PHP code example of patrick-hull / mysql-wrapper

1. Go to this page and download the library: Download patrick-hull/mysql-wrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

patrick-hull / mysql-wrapper example snippets


use PatrickHull\MysqlWrapper\DbConnection;

$dbConnection = new DbConnection('server_address', 'username', 'password');
$link = $dbConnection->connect();

use PatrickHull\MysqlWrapper\DeleteQuery;

$deleteQuery = new DeleteQuery($link);
$deleteQuery->database = 'your_database';
$deleteQuery->table = 'your_table';
$deleteQuery->criteria = ['column_name' => 'value'];

$result = $deleteQuery->Execute();

use PatrickHull\MysqlWrapper\InsertQuery;

$insertQuery = new InsertQuery($link);
$insertQuery->database = 'your_database';
$insertQuery->table = 'your_table';
$insertQuery->data = ['column1' => 'value1', 'column2' => 'value2'];

$result = $insertQuery->Execute();

use PatrickHull\MysqlWrapper\UpdateQuery;

$updateQuery = new UpdateQuery($link);
$updateQuery->database = 'your_database';
$updateQuery->table = 'your_table';
$updateQuery->data = ['column1' => 'new_value'];
$updateQuery->criteria = ['column_name' => 'value'];

$result = $updateQuery->Execute();

use PatrickHull\MysqlWrapper\SelectQuery;

$selectQuery = new SelectQuery($link);
$selectQuery->database = 'your_database';
$selectQuery->table = 'your_table';
$selectQuery->criteria = ['column_name' => 'value'];
$selectQuery->limit = 10;

$result = $selectQuery->Execute();

use PatrickHull\MysqlWrapper\SelectQuery;

$selectQuery = new SelectQuery($link);
$selectQuery->database = 'your_database';
$selectQuery->table = 'your_table';
$selectQuery->criteria = ['column_name' => 'value'];
$selectQuery->redis = true;
$selectQuery->redis_pw = "password";
$selectQuery->cache_duration = "200" //Number of Seconds the cache is live
$selectQuery->limit = 10;

$result = $selectQuery->Execute();