1. Go to this page and download the library: Download arthur-rmd/php-easy-sql 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/ */
arthur-rmd / php-easy-sql example snippets
exemple :
class DbConfig
{
private $configLink = "../../config.json";
...
}
Db::setLink('../../config.json');
DbConfig::getData();
// renvoie un tableau avec toutes les informations contenue dans le fichier config.json
//['sgbd' => 'mysql', 'serveur' => 'localhost', 'login' => 'root', 'pass','mot_de_passe' 'base' => 'nom_de_la_base']
DbConfig::getData('sgbd'); // renvoie 'mysql'
$link = DbConfig::getLink();
echo $link // renvoie la chaine "config.json"
DbConfig::setLink('../../config.json');
$pdo = DbConfig::getPdo();
$pdo->query('select * from users');
DbConfig::close();
Db::select('select * from users');
Db::select('select * from users where prenom like "Arthur"');
Db:query("insert into users values ('prenom') value ('Arthur') ");
Db::select('select * from users where prenom like :prenom',['prenom' => 'Arthur'] );
$var = 'Arthur';
Db:query("insert into users values ('prenom') value (:prenom) ", ['prenom' => $var]);
Db::selectAll('users');
Db::selectAll('users', ['prenom', '=', 'Arthur']);
Db::selectAll('users', ['prenom','Arthur']);
// Les deux résulat seront identique
Db::selectAll('users', ['id', '>', '10']);
Db::find('users', 5);
// est égale a la requête suivante
// select * from users where id = 5;
class Db extends DbQuery {
public static function ageBetween($ageMin,$ageMax)
{
return self::select('select * from users where age > :ageMin and age < :ageMax', ['ageMin' => $ageMin, 'ageMax' => $ageMax]);
}
}
Db::ageBetween(18,25);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.