1. Go to this page and download the library: Download junker/hsal 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/ */
junker / hsal example snippets
use HSAL\HSAL;
$hs = new HSAL('localhost', 'database');
//SELECT id,title FROM pages WHERE id=5
$page = $hs->fetchAssoc('pages',
['id', 'title'],
[HSAL::INDEX_PRIMARY => 5]
);
print_r($page); // ['id' => 5, 'title' => 'page number 5']
//SELECT title FROM pages WHERE id=5
$title = $hs->fetchColumn('pages', 'title', [HSAL::INDEX_PRIMARY => 5]);
print_r($title); // page number 5
//SELECT id,page_id,title FROM pages_lang WHERE page_id=5 AND language_id=2
$page = $hs->fetchArray('pages_lang',
['id', 'page_id', 'title'],
['page_lang' => [5,2]]
);
print_r($title); // [21, 5, 'numéro de la page 5']
//SELECT id,title FROM pages WHERE view_count>10 LIMIT 5
$pages = $hs->fetchAll('pages',
['id', 'title'],
['view_count' => 10],
HSAL::OPERATOR_GREATER,
5
);
print_r($pages);
// [['id' => 4, 'title' => 'page number 4'], ['id' => 5, 'title' => 'page number 5']]
//can make request to another database(i.e. dev_database) without creating new HSAL instance
//SELECT title FROM dev_database.pages WHERE id=5
$title = $hs->fetchColumn('dev_database.pages', 'title', [HSAL::INDEX_PRIMARY => 5]);