For example I have a class named user :
class User
{
public $nome;
private $email;
protected $senha;
public function __construct(){
}
public function insert($email, $senha){
require_once "conexao.php";
$pdo = conectar();
$insertSQL = $pdo->prepare('INSERT INTO tbl (valores) VALUES (?)');
$insertSQL->bindValue(1, $this->lalala(), PDO::PARAM_STR);
$insertSQL->execute();
}
and also see that I need to make require ():
require_once "conexao.php";
$pdo = connect();
But I have to do these two lines every time for every method of the class. There is no way to create a single time and be available throughout the class scope, type the attributes?
I've tried it as an attribute and it did not work. With the builder it also was not (maybe I did it wrong).