HomeFairfax General ForumArrest/Ticket SearchWiki newPictures/VideosChatArticlesLinksAbout
Loudoun :  Fairfax Underground fairfax underground logo
Welcome to Fairfax Underground, a project site designed to improve communication among residents of Fairfax County, VA. Feel free to post anything Northern Virginia residents would find interesting.
execute
Posted by: Sexecute ()
Date: January 30, 2022 09:14PM

<?php

/**
* PHP MySQL Delete Data Demo
*/
class DeleteDataDemo {

const DB_HOST = 'localhost';
const DB_NAME = 'phorum';
const DB_USER = 'root';
const DB_PASSWORD = 'ffxupassword';

/**
* PDO instance
* @var PDO
*/
private $pdo = null;

/**
* Open a database connection to MySQL
*/
public function __construct() {
// open database connection
$conStr = sprintf("mysql:host=%s;dbname=%s", self::DB_HOST, self::DB_NAME);
try {
$this->pdo = new PDO($conStr, self::DB_USER, self::DB_PASSWORD);
} catch (PDOException $e) {
die($e->getMessage());
}
}

/**
* Delete a task based on a specified task id
* @param int $id
* @return bool true on success or false on failure
*/
public function delete($id) {

$sql = 'DELETE FROM tasks
WHERE task_id = :task_id';

$q = $this->pdo->prepare($sql);

return $q->execute([':task_id' => $id]);
}

/**
* close the database connection
*/
public function __destruct() {
$this->pdo = null;
}

}

$obj = new DeleteDataDemo();
// delete id 2
$obj->delete(2);

Options: ReplyQuote


Your Name: 
Your Email (Optional): 
Subject: 
Attach a file
  • No file can be larger than 75 MB
  • All files together cannot be larger than 300 MB
  • 30 more file(s) can be attached to this message
Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically.
 ********  **      **  **    **  ********   ********  
 **        **  **  **  ***   **  **     **  **     ** 
 **        **  **  **  ****  **  **     **  **     ** 
 ******    **  **  **  ** ** **  ********   **     ** 
 **        **  **  **  **  ****  **     **  **     ** 
 **        **  **  **  **   ***  **     **  **     ** 
 ********   ***  ***   **    **  ********   ********  
This forum powered by Phorum.