示例#1
0
 public function __construct()
 {
     $connection = new DBconfig();
     // database connection
     $this->connection = $connection->connectToDatabase();
     $this->helper = new helper();
     // calling helper class
 }
示例#2
0
 public function __construct()
 {
     $connection = new DBconfig();
     $this->connection = $connection->connectToDatabase();
 }
示例#3
0
 public function delete($tablename, $condition)
 {
     //delete data
     $dbconfig = new DBconfig();
     $host = $dbconfig->host();
     $user = $dbconfig->username();
     $pwd = $dbconfig->pwd();
     $db = $dbconfig->db();
     try {
         $conn = new PDO("mysql:host={$host};dbname={$db}", $user, $pwd);
         // set the PDO error mode to exception
         $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         $sql = "DELETE FROM " . $tablename . " WHERE (" . $condition . ")";
         // use exec() because no results are returned
         $conn->exec($sql);
         return true;
     } catch (PDOException $e) {
         echo $sql . "<br>" . $e->getMessage();
         return false;
     }
     $conn = null;
 }