fork download
  1. class Model {
  2. public function getAllArticles(){
  3. $dbh = new PDO($dsn, $user, $pass);
  4. $query = "SELECT * FROM my_table";
  5. return $dbh->query($query);
  6. }
  7. public function save($title, $article){
  8. $dbh = new PDO($dsn, $user, $pass);
  9. $query = "INSERT INTO my_table (title, article) VALUES ('$title', '$article')";
  10. $dbh->query($query);
  11. }
  12. }
Success #stdin #stdout 0.01s 24400KB
stdin
Standard input is empty
stdout
class Model {
  public function getAllArticles(){
    $dbh = new PDO($dsn, $user, $pass);
    $query = "SELECT * FROM my_table";
    return $dbh->query($query);
  }
  public function save($title, $article){
    $dbh = new PDO($dsn, $user, $pass);
    $query = "INSERT INTO my_table (title, article) VALUES ('$title', '$article')";
    $dbh->query($query);
  }
}