PHP code example of invincible-tech-systems / easeampmysql
1. Go to this page and download the library: Download invincible-tech-systems/easeampmysql 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' );
invincible-tech-systems / easeampmysql example snippets
InvincibleTechSystems\EaseAmpMysql\EaseAmpMysql;
use \InvincibleTechSystems \EaseAmpMysql \CustomAmphpDnsConfigLoader ;
$customAmphpDnsConfigValues = ["208.67.222.222:53" , "208.67.220.220:53" ,"8.8.8.8:53" ,"[2001:4860:4860::8888]:53" ];
$CustomAmphpDnsConfigLoader = new CustomAmphpDnsConfigLoader($customAmphpDnsConfigValues, 5000 , 3 );
\Amp\Dns\resolver(new \Amp\Dns\Rfc1035StubResolver(null , $CustomAmphpDnsConfigLoader));
$dbHost = "localhost" ;
$dbUsername = "database_username" ;
$dbPassword = "database_password_value" ;
$dbName = "database_name" ;
$dbConn = new EaseAmpMysql($dbHost, $dbUsername, $dbPassword, $dbName);
`INSERT Query (with Named Parameters as placeholders):`
$query = "INSERT INTO `site_members`(`sm_firstname`, `sm_lastname`) VALUES (:sm_firstname,:sm_lastname)" ;
$values_array = array (':sm_firstname' => 'First Name' ,':sm_lastname' => 'Last Name' );
$queryResult = $dbConn->executeQuery($query, $values_array, "insertWithIntegerAsPrimaryKey" );
`UPDATE Query (with Named Parameters as placeholders):`
$query = "UPDATE `site_members` SET `sm_firstname`=:sm_firstname, `sm_lastname`=:sm_lastname WHERE `sm_memb_id`=:sm_memb_id" ;
$values_array = array (':sm_firstname' => 'Srirama' ,':sm_lastname' => 'D' ,':sm_memb_id' => 2 );
$queryResult = $dbConn->executeQuery($query, $values_array, "update" );
`SELECT Query (with Named Parameters as placeholders):`
$query = "SELECT * FROM `site_members` WHERE `sm_memb_id`=:sm_memb_id" ;
$values_array = array (':sm_memb_id' => 1 );
$queryResult = $dbConn->executeQuery($query, $values_array, "selectSingle" );
`SELECT ALL Query (with Named Parameters as placeholders):`
$query = "SELECT * FROM `site_members`" ;
$values_array = array ();
$queryResult = $dbConn->executeQuery($query, $values_array, "selectMultiple" );
`DELETE Query (with Named Parameters as placeholders):`
$query = "DELETE FROM `site_members` WHERE `sm_memb_id`=:sm_memb_id" ;
$values_array = array (':sm_memb_id' => 4 );
$queryResult = $dbConn->executeQuery($query, $values_array, "delete" );
`INSERT Query (with Named Parameters as placeholders):`
$query = "INSERT INTO `site_members`(`sm_firstname`, `sm_lastname`) VALUES (:sm_firstname,:sm_lastname)" ;
$values_array = array (':sm_firstname' => 'First Name' ,':sm_lastname' => 'Last Name' );
$preparedQuery = $dbConn->prepareQuery($query);
$queryResult = $dbConn->runPreparedQuery($preparedQuery, $values_array, "insertWithIntegerAsPrimaryKey" );
`UPDATE Query (with Named Parameters as placeholders):`
$query = "UPDATE `site_members` SET `sm_firstname`=:sm_firstname, `sm_lastname`=:sm_lastname WHERE `sm_memb_id`=:sm_memb_id" ;
$values_array = array (':sm_firstname' => 'Srirama' ,':sm_lastname' => 'D' ,':sm_memb_id' => 2 );
$preparedQuery = $dbConn->prepareQuery($query);
$queryResult = $dbConn->runPreparedQuery($preparedQuery, $values_array, "update" );
`SELECT Query (with Named Parameters as placeholders):`
$query = "SELECT * FROM `site_members` WHERE `sm_memb_id`=:sm_memb_id" ;
$values_array = array (':sm_memb_id' => 1 );
$preparedQuery = $dbConn->prepareQuery($query);
$queryResult = $dbConn->runPreparedQuery($preparedQuery, $values_array, "selectSingle" );
`SELECT ALL Query (with Named Parameters as placeholders):`
$query = "SELECT * FROM `site_members`" ;
$values_array = array ();
$preparedQuery = $dbConn->prepareQuery($query);
$queryResult = $dbConn->runPreparedQuery($preparedQuery, $values_array, "selectMultiple" );
`DELETE Query (with Named Parameters as placeholders):`
$query = "DELETE FROM `site_members` WHERE `sm_memb_id`=:sm_memb_id" ;
$values_array = array (':sm_memb_id' => 4 );
$preparedQuery = $dbConn->prepareQuery($query);
$queryResult = $dbConn->runPreparedQuery($preparedQuery, $values_array, "delete" );