Ejemplo n.º 1
0
 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();
     }
 }
Ejemplo n.º 2
0
 public function delete_posts()
 {
     $M = mysqli_db::getInstance();
     $sql = "DELETE FROM posts";
     $M->query($sql);
 }