this here below is my class database in php
<?php
class DB
{
private $SQLcommand;
private $bd;
public function setSQLcommand($valor)
{
$this->SQLcommand = $valor;
}
public function getSQLcommand()
{
return($this->SQLcommand);
}
function __construct()
{
$this->bd = new PDO("mysql:host=localhost;dbname=cpd", "root", "");
}
public function ExecSQL()
{
if ($this->SQLcommand != "")
return($this->bd->exec($this->SQLcommand));
else
return(false);
}
public function ExecSelect()
{
if ($this->SQLcommand != "")
{
$data = $this->bd->query($this->SQLcommand);
return($data->fetchAll());
}
else
return(false);
}
function __destruct()
{
$this->bd = null;
}
}
?>
and here is how I instantiate
include_once 'db_class.php';
$e = new DB();
$e->setSQLcommand("INSERT INTO characteristic (id_charac,name_charac)
VALUES ('','".$_POST["nomecharac"]."')");
$e->ExecSQL();
$p = new DB();
$p->setSQLcommand("select * from characteristic");
$data = $p->ExecSelect();
I would ask where in the code I can I put a try catch, that if an error occurs the try catch redirects to the file maintenance.php, and prevent the bank's User and password are showed...thank you all...