Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'database.php';
- /**
- * Profile Class
- */
- class Profile
- {
- private $conn;
- public function __construct()
- {
- $database = new Database();
- $db = $database->dbConnection();
- $this->conn = $db;
- }
- public function runQuery($sql)
- {
- $stmt = $this->conn->prepare($sql);
- return $stmt;
- }
- public function insertProfile($nama, $photo)
- {
- try {
- $stmt = $this->conn->prepare(
- "INSERT INTO profile(nama,photo)
- VALUES(:nama,:photo)"
- );
- $stmt->bindParam(':nama', $nama);
- $stmt->bindParam(':photo', $photo);
- $stmt->execute();
- return $stmt;
- } catch (PDOException $e) {
- echo $e->getMessage();
- }
- }
- public function updateProfile($nama, $photo, $ipro)
- {
- try {
- $stmt = $this->conn->prepare(
- "UPDATE profile
- SET nama=:nama,
- photo=:photo
- WHERE id_profile=:ipro"
- );
- $stmt->bindParam(':nama', $nama);
- $stmt->bindParam(':photo', $photo);
- $stmt->bindParam(':ipro', $ipro);
- $stmt->execute();
- return $stmt;
- } catch (PDOException $e) {
- echo $e->getMessage();
- }
- }
- public function deleteProfile($ipro)
- {
- if (isset($_GET['delete_ipro'])) {
- $stmt = $this->conn->prepare(
- "DELETE FROM profile WHERE id_profile=:ipro"
- );
- $stmt->bindParam(':ipro', $_GET['delete_ipro']);
- $stmt->execute();
- return $stmt;
- }
- }
- public function redirect($url, $statusCode = 303)
- {
- header('Location: ' . $url, true, $statusCode);
- die();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement