Good afternoon
Personal I'm trying to get the ID that was entered by my class but without success. 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();
}
**** CLASS CONNECT ******* 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);
}
}