/**
  * {@inheritdoc}
  */
 public function add(Article $article)
 {
     $id = $article->getIdentifier();
     $params = [':title' => $article->getTitle(), ':body' => $article->getBody(), ':year' => $article->getYear()];
     $bind = [':year' => \PDO::PARAM_INT];
     if ($id) {
         $sql = 'UPDATE ' . self::TABLE . ' SET title = :title, body = :body, publish_year = :year WHERE id = :id';
         $params[':id'] = $id;
         $bind[':id'] = \PDO::PARAM_INT;
     } else {
         $sql = 'INSERT INTO ' . self::TABLE . ' (title, body, publish_year) VALUES (:title, :body, :year)';
     }
     $stm = $this->conn->prepare($sql);
     foreach ($params as $name => $val) {
         $stm->bindValue($name, $val, isset($bind[$name]) ? $bind[$name] : \PDO::PARAM_STR);
     }
     $stm->execute();
     return $id ? $id : intval($this->conn->lastInsertId());
 }
			<div class="content">
					<h3>
						<span>
							<?php 
echo ACCESS_STATS;
?>
						</span>
					</h3>
					<div>
					<?
							echo '<a target="_blank" href="'.$article->getUrl().'" >'.getTitle($article->getTitle())."<a/><br>\n";
							echo '</a></b>'."\n";
							echo '<i>';
							echo getAutors($article->getAuthorXML());
							echo '</i><br />';
							echo '<i>'.$article->getSerial(). ', '.$article->getYear().', vol:'.$article->getVolume();
							echo ', n. '.$article->getNumber().', ISSN '.substr($article->getPID(),1,9).'</i><br/><br/>'."\n";
						?>
					</div>
					<div>
						<img src="createAccessChart.php?pid=<?php 
echo $pid;
?>
" />
						<br /><br />
					</div>
					<div>
						<a href="/users/myAlerts.php"><?php 
echo BUTTON_BACK;
?>
</a>
Example #3
0
 /**
 * Adiciona um artigo à base
 *
 * @param Article $article Objeto Artigo
 *
 * Ele pega os dados que estão armazenados nos campos da classe e adiciona no Banco
 * @returns mixed $result
 */
 function AddArticle($article)
 {
     $strsql = "INSERT INTO scieloorgusers.articles (\r\n\t\tPID, \r\n\t\turl,\r\n\t\ttitle, \r\n\t\tserial, \r\n\t\tvolume, \r\n\t\tnumber, \r\n\t\tsuppl, \r\n\t\tyear, \r\n\t\tauthors_xml, \r\n\t\tkeywords_xml,\r\n\t\tabstract_xml,\r\n\t\tprocess_date,\r\n\t\tpublication_date,\r\n\t\twp_post_id,\r\n\t\twp_url,\r\n\t\twp_post_date\r\n\t\t) \r\n\t\tVALUES ('" . $article->getPID() . "','" . $article->getURL() . "','" . mysql_escape_string(str_replace("'", "&apos;", $article->getTitle())) . "','" . $article->getSerial() . "','" . $article->getVolume() . "','" . $article->getNumber() . "','" . $article->getSuppl() . "','" . $article->getYear() . "','" . mysql_escape_string($article->getAuthorXML()) . "','" . mysql_escape_string(str_replace("'", "&apos;", $article->getKeywordXML())) . "','" . mysql_escape_string(str_replace("'", "&apos;", $article->getAbstractXML())) . "','" . date('Y-m-d H:i:s') . "','" . formatDate($article->getPublicationDate()) . "'," . $article->getWpPostID() . ",'" . $article->getWpURL() . "','" . $article->getWpPostDate() . "'" . ")";
     $result = $this->_db->databaseExecInsert($strsql);
     return $result;
 }