$this->_data = array();
if(!empty($hash)) {
- $queryStr = "SELECT * FROM `".DB_PREFIX."_link`
- WHERE `hash` = '".$this->DB->real_escape_string($hash)."'";
+ $queryStr = "SELECT
+ any_value(`id`) as id,
+ any_value(`link`) as link,
+ any_value(`created`) as created,
+ any_value(`status`) as status,
+ any_value(`description`) as description,
+ any_value(`title`) as title,
+ any_value(`image`) as image,
+ any_value(`hash`) as hash
+ FROM `".DB_PREFIX."_link`
+ WHERE `hash` = '".$this->DB->real_escape_string($hash)."'";
$query = $this->DB->query($queryStr);
if(!empty($query) && $query->num_rows == 1) {
$ret = $query->fetch_assoc();
$ret = false;
if(!empty($link)) {
- $queryStr = "SELECT * FROM `".DB_PREFIX."_link`
- WHERE `link` = '".$this->DB->real_escape_string($link)."'";
+ $queryStr = "SELECT
+ any_value(`hash`) as hash
+ FROM `".DB_PREFIX."_link`
+ WHERE `link` = '".$this->DB->real_escape_string($link)."'";
$query = $this->DB->query($queryStr);
if(!empty($query) && $query->num_rows > 0) {
$result = $query->fetch_assoc();
$ret = array();
if(!empty($this->_data['hash'])) {
- $queryStr = "SELECT DISTINCT(tag) FROM `".DB_PREFIX."_combined`
- WHERE `hash` = '".$this->DB->real_escape_string($this->_data['hash'])."'";
+ $queryStr = "SELECT
+ DISTINCT(tag) as tag
+ FROM `".DB_PREFIX."_combined`
+ WHERE `hash` = '".$this->DB->real_escape_string($this->_data['hash'])."'";
$query = $this->DB->query($queryStr);
if(!empty($query) && $query->num_rows > 0) {
while($result = $query->fetch_assoc()) {
if($result['tag'] !== NULL) {
- $ret[] = $result['tag'];
+ $ret[$result['tag']] = $result['tag'];
}
}
$ret = array();
if(!empty($this->_data['hash'])) {
- $queryStr = "SELECT DISTINCT(category) FROM `".DB_PREFIX."_combined`
- WHERE `hash` = '".$this->DB->real_escape_string($this->_data['hash'])."'";
+ $queryStr = "SELECT
+ DISTINCT(category) FROM `".DB_PREFIX."_combined`
+ WHERE `hash` = '".$this->DB->real_escape_string($this->_data['hash'])."'";
$query = $this->DB->query($queryStr);
if(!empty($query) && $query->num_rows > 0) {
while($result = $query->fetch_assoc()) {
if($result['category'] !== NULL) {
- $ret[] = $result['category'];
+ $ret[$result['category']] = $result['category'];
}
}
}
if(!empty($this->_data['id'])) {
$queryStr = false;
if($tagid === false) {
- $queryStr = "DELETE FROM `".DB_PREFIX."_tagrelation`
- WHERE `linkid` = '".$this->DB->real_escape_string($this->_data['id'])."'";
+ $queryStr = "DELETE
+ FROM `".DB_PREFIX."_tagrelation`
+ WHERE `linkid` = '".$this->DB->real_escape_string($this->_data['id'])."'";
}
elseif(is_numeric($tagid)) {
- $queryStr = "DELETE FROM `".DB_PREFIX."_tagrelation`
- WHERE `linkid` = '".$this->DB->real_escape_string($this->_data['id'])."'
- AND `tagid` = '".$this->DB->real_escape_string($tagid)."'";
+ $queryStr = "DELETE
+ FROM `".DB_PREFIX."_tagrelation`
+ WHERE `linkid` = '".$this->DB->real_escape_string($this->_data['id'])."'
+ AND `tagid` = '".$this->DB->real_escape_string($tagid)."'";
}
if(!empty($queryStr)) {
$this->DB->query($queryStr);
if(!empty($this->_data['id'])) {
$queryStr = false;
if($categoryid === false) {
- $queryStr = "DELETE FROM `".DB_PREFIX."_categoryrelation`
- WHERE `linkid` = '".$this->DB->real_escape_string($this->_data['id'])."'";
+ $queryStr = "DELETE
+ FROM `".DB_PREFIX."_categoryrelation`
+ WHERE `linkid` = '".$this->DB->real_escape_string($this->_data['id'])."'";
}
elseif(is_numeric($categoryid)) {
- $queryStr = "DELETE FROM `".DB_PREFIX."_categoryrelation`
- WHERE `linkid` = '".$this->DB->real_escape_string($this->_data['id'])."'
- AND `categoryid` = '".$this->DB->real_escape_string($categoryid)."'";
+ $queryStr = "DELETE
+ FROM `".DB_PREFIX."_categoryrelation`
+ WHERE `linkid` = '".$this->DB->real_escape_string($this->_data['id'])."'
+ AND `categoryid` = '".$this->DB->real_escape_string($categoryid)."'";
}
if(!empty($queryStr)) {
$this->DB->query($queryStr);
* Insipid
* Personal web-bookmark-system
*
- * Copyright 2016-2018 Johannes Keßler
+ * Copyright 2016-2019 Johannes Keßler
*
* Development starting from 2011: Johannes Keßler
* https://www.bananas-playground.net/projekt/insipid/
$searchValue = str_replace("'", "", $searchValue);
$searchValue = str_replace('"', "", $searchValue);
- $queryStr = "SELECT *, MATCH (search)
- AGAINST ('".$DB->real_escape_string($searchValue)."*' IN BOOLEAN MODE) AS score
- FROM `".DB_PREFIX."_link`
- WHERE MATCH (search)
- AGAINST ('".$DB->real_escape_string($searchValue)."*' IN BOOLEAN MODE)
- ORDER BY score DESC";
+ $queryStr = "SELECT *,
+ MATCH (search) AGAINST ('".$DB->real_escape_string($searchValue)."*' IN BOOLEAN MODE) AS score
+ FROM `".DB_PREFIX."_link`
+ WHERE MATCH (search) AGAINST ('".$DB->real_escape_string($searchValue)."*' IN BOOLEAN MODE)
+ ORDER BY score DESC";
}
else {
$submitFeedback['message'] = 'Invalid input';
$submitFeedback['status'] = 'error';
}
- #var_dump($queryStr);
-
if(!empty($queryStr)) {
$query = $DB->query($queryStr);
if(!empty($query) && $query->num_rows > 0) {