Ejemplo n.º 1
0
 function insert($db, $article, $database)
 {
     require_once "journals.php";
     $journal_model = new Journals();
     // Insert journal, if the journal already exists the existing journal_id is returned
     $journal_id = $journal_model->insert($db, $article["journal_title"], $article["journal_iso"], $article["journal_issn"]);
     // Insert article
     // Strip title of any characters other than a-z, used to compare articles to each other
     $title_stripped = preg_replace("/[^a-z]/i", "", strtolower($article["title"]));
     $title_fixed = addslashes($article["title"]);
     $abstract_fixed = addslashes($article["abstract"]);
     $sql = "INSERT INTO Articles (title, title_stripped, abstract, journal, day, month, year, doi, search_db) \n      VALUES ('{$title_fixed}', '{$title_stripped}', '{$abstract_fixed}', '{$journal_id}', '{$article['day']}', \n        '{$article['month']}', '{$article['year']}', '{$article['doi']}', '{$database}')";
     if ($result = $db->query($sql)) {
         $article_id = $db->connection->insert_id;
         return $article_id;
     }
     return false;
 }