コード例 #1
0
ファイル: users.php プロジェクト: azfarahmed/easyphp
 public function __construct()
 {
     $connection = new DBconfig();
     // database connection
     $this->connection = $connection->connectToDatabase();
     $this->helper = new helper();
     // calling helper class
 }
コード例 #2
0
ファイル: home.php プロジェクト: azfarahmed/easyphp
 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;
 }