I have two different banks that I make the connection in the following way:
date_default_timezone_set('America/Sao_Paulo');
abstract class BancoDados
{
const host = 'localhost';
const novoweb = 'novoweb';
const WebAccount = 'Web_Account';
const Member = 'Member';
const user = 'usuario';
const password = 'senha';
static function conectarW()
{
try
{
$pdoW = new PDO("mysql:host=".self::host.";dbname=".self::novoweb.";charset=utf8", self::user, self::password);
$pdoW->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $pdoW;
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
}
static function conectarWA()
{
try
{
$pdoWA = new PDO("mysql:host=".self::host.";dbname=".self::WebAccount.";charset=utf8", self::user, self::password);
$pdoWA->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $pdoWA;
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
}
}
I have two values in the novoweb
database in the shopweb
table with the id
and nome
columns, where id
I enter the Web_Account
database in the GameTail table in the ItemIdx
column but I do not know how do INNER JOIN
because I make the query like this.
static function historicoshopweb($pdoWA,$id,$admin)
{
try {
if ($admin == 1) {
$historico = $pdoWA->prepare("SELECT * FROM GameTail ORDER BY RegDate DESC");
$historico->execute();
} else {
$historico = $pdoWA->prepare("SELECT * FROM GameTail WHERE IdIdx = :id ORDER BY RegDate DESC");
$historico->bindValue(":id",$id);
$historico->execute();
}
$historicos = $historico->fetchAll(PDO::FETCH_OBJ);
return $historicos;
} catch (PDOException $e) {
echo "ERROR: ".$e->getMessage();
}
}
Then I want instead of the ItemIdx
to appear the name of the item.