-
-
Save victorknust/9c1ee268b6773239181b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'C:\xampp\htdocs\PainelOO\classes\DB\DB.php'; | |
abstract class Crud extends DB{ | |
protected $table; | |
abstract public function insert(); | |
abstract public function update($id); | |
public function find($id){ | |
$sql = "SELECT * FROM $this->table WHERE id = :id"; | |
$stmt = DB::prepare($sql); | |
$stmt->bindParam(':id', $id, PDO::PARAM_INT); | |
$stmt->execute(); | |
return $stmt->fetch(); | |
} | |
public function findAll(){ | |
$sql = "SELECT * FROM $this->table"; | |
$stmt = DB::prepare($sql); | |
$stmt->execute(); | |
return $stmt->fetchAll(); | |
} | |
public function delete($id){ | |
$sql = "DELETE FROM $this->table WHERE id = :id"; | |
$stmt = DB::prepare($sql); | |
$stmt->bindParam(':id', $id, PDO::PARAM_INT); | |
return $stmt->execute(); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment