Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function __autoload($class) {
- $class = strtolower($class);
- // Inclui a classe que precisamos
- include_once("classes/class-{$class}.php");
- }
- class ConnectionFactory{
- static function getConnection(){
- $con = new PDO("mysql:host=localhost;dbname=projeto_php_pdo", "root", "");
- return $con;
- }
- }
- class metodosPDO {
- function __autoload($class) {
- $class = strtolower($class);
- // Inclui a classe que precisamos
- include_once("classes/class-{$class}.php");
- }
- static function inserirCliente($nome, $sobrenome) {
- $con = ConnectionFactory::getConnection();
- $stmt = $con->prepare("INSERT INTO pessoa(nome, sobrenome) VALUES(?, ?)");
- $stmt->bindParam(1, $nome);
- $stmt->bindParam(2, $sobrenome);
- $stmt->execute();
- $stmt->close();
- return;
- }
- }
- <?PHP
- // INCLUIR AQUI
- ?>
- <form action="#" method="post">
- <input type="text" name="nome" value="" />
- <input type="text" name="sobrenome" value="" />
- <input type="submit" value="Cadastrar" name="btn" />
- </form>
- <?php
- $nome = $_POST['nome'];
- $sobrenome = $_POST['sobrenome'];
- $verf = metodosPDO::inserirCliente($nome, $sobrenome);
- ?>
Add Comment
Please, Sign In to add comment