/** * Gives the book ID from a given isbn (!) barcode */ function getBookIDByISBN($isbn) { require_once PATH_ACCESS . '/DBConnect.php'; $query = sql_prev_inj(sprintf('isbn = "%s"', $isbn)); $result = parent::searchEntry($query); if (!$result) { /** * @todo Proper Errorhandling here, not this: (wouldnt even execute) * throw DB_QUERY_ERROR.$this->db->error; */ } return $result; }
function getInvIDByBarcode($barcode) { require_once PATH_ACCESS . '/DBConnect.php'; $bookmanager = new BookManager(); $barcode = str_replace("-", "/", $barcode); // replace - with / $barcode = preg_replace("/\\/([0-9])/", "/ \$1", $barcode); //add space after / when it's missing $barcode = str_replace(" ", " ", $barcode); // remove two empty spaces $bookData = $bookmanager->getBookDataByBarcode($barcode); try { $barcode_exploded = explode(' ', $barcode); } catch (Exception $e) { } if (isset($bookData["id"]) && isset($barcode_exploded[5])) { $query = sql_prev_inj(sprintf('book_id = %s AND year_of_purchase = %s AND exemplar = %s', $bookData["id"], $barcode_exploded[1], $barcode_exploded[5])); $result = parent::searchEntry($query); return $result['id']; } }
/** * returns the GroupID which has the given name * If there are multiple groups with the same name, it will return the ID of the first Group it found * @param string $str the name of the Group to search for */ function getGroupIDByName($str) { $group = parent::searchEntry(sprintf('name = "%s"', $str)); return $group['ID']; }