journal_name = $name; return; } public function setVolumeIssue($volumeIssue) { /* volume (issue) */ $vi = explode ("(", preg_replace('/[^\d(]/', '', $volumeIssue)); $this->volume = preg_replace ('/\D/', '', $vi[0]); if (count ($vi)>1) { $this->issue = preg_replace ('/\D/', '', $vi[1]); } return; } public function setVolume($volume) { /* volume (issue) */ $this->volume = preg_replace ('/\D/', '', $volume); return; } public function setIssue($issue) { $this->issue = preg_replace ('/\D/', '', $issue); return; } // each type has its own master record // THIS ONLY ADDS article (master of publication) protected function _addMaster() { $this->type = 1; if (!$this->_isJournal()) { if (!$this->_addJournal()) { common::except ('Err cannot add journal, terminating (in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__ .')'); return false; } } if (!$this->_isArticle()) { if (!$this->_addArticle()) { common::except ('Err cannot add journal article, terminating (in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__ .')'); return false; } } return $this->article_id; } private function _isArticle() { try { $stmt = $this->PDO->prepare("SELECT id FROM p_journalArticle WHERE id_journal=:id_journal AND volume=:volume AND issue=:issue AND fromPage=:fromPage AND toPage=:toPage"); $stmt->execute(array( 'id_journal' => $this->journal_id, 'volume' => $this->volume, 'issue' => $this->issue, 'fromPage' => $this->fromPage, 'toPage' => $this->toPage)); // this instead of rowCount to make in compatible with non-mysql DB if ($r = $stmt->fetch(PDO::FETCH_NUM)) { $this->article_id = $r[0]; return true; } return false; } catch (exception $ex) { common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__); } } private function _addArticle() { try { $stmt = $this->PDO->prepare("INSERT INTO p_journalArticle (id_journal, volume, issue, fromPage, toPage) VALUES (:id_journal, :volume, :issue, :fromPage, :toPage)"); $stmt->execute(array( 'id_journal' => $this->journal_id, 'volume' => intval($this->volume), 'issue' => intval($this->issue), 'fromPage' => intval($this->fromPage), 'toPage' => intval($this->toPage))); $this->article_id = $this->PDO->lastInsertId(); return true; } catch (exception $ex) { common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__); } } private function _addJournal() { try { $stmt = $this->PDO->prepare("INSERT INTO l_journal (name) VALUES (:name)"); $stmt->execute(array($this->journal_name)); $this->journal_id = $this->PDO->lastInsertId(); return true; } catch (exception $ex) { common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__); return false; } } private function _isJournal() { try { for ($x=1; $x<=2; $x++) { $stmt = $this->PDO->prepare("SELECT id FROM l_journal where name=:name " .($x==1?'AND id_issn!="" ':'') ." order by id asc"); $stmt->execute(array($this->journal_name)); // this instead of rowCount to make in compatible with non-mysql DB if ($r = $stmt->fetch(PDO::FETCH_NUM)) { $this->journal_id = $r[0]; return true; } } return false; } catch (exception $ex) { common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__); } } }