public function __construct($strategy) { $dbm = array('mysql', 'mysqli', 'pgsql'); if (in_array($strategy, $dbm) === false) { throw new Exception('Invalid parameter for Data Base Strategy'); } try { switch ($strategy) { case 'mysql': $this->strategy = mysql_db::getInstance(); break; case 'mysqli': $this->strategy = mysqli_db::getInstance(); break; case 'pgsql': $this->strategy = pgsql_db::getInstance(); break; } } catch (Exception $e) { echo $e->getMessage(); } }
public function delete_posts() { $M = mysqli_db::getInstance(); $sql = "DELETE FROM posts"; $M->query($sql); }