1
Good afternoon
Guys I’m trying to get the ID that was entered by my class but unsuccessfully. The examples I found none worked. If anyone can help, thank you.
public function insert_orcamento($numero, $cod_cliente) {
$sql = "INSERT INTO $this->table (numero, cod_cliente)"
. "VALUES (:numero, :cod_cliente )";
$stmt = Conecta::prepare($sql);
$stmt->bindParam(':numero', $numero);
$stmt->bindParam(':cod_cliente', $cod_cliente);
return $stmt->execute();
}
****CONNECT CLASS******* require_once dirname(DIR).DIRECTORY_SEPARATOR.'config'. DIRECTORY_SEPARATOR.'config.php';
class Connects {
private static $instance;
public static function getInstance() {
if (!isset(self::$instance)) {
try {
self::$instance = new PDO('mysql:host=' . DB_HOST . ';dbname='.DB_NAME, DB_USER, DB_PASS);
self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
self::$instance->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
} catch (PDOException $e) {
echo $e->getMessage();
}
}
return self::$instance;
}
public static function prepare($sql) {
return self::getInstance()->prepare($sql);
}
}
Enter the code of your class
Conecta
also please.– RFL
I just put her there.
– Maicon Fernando Stefene da Sil