More fixes

This commit is contained in:
DariusIII
2014-04-13 20:35:22 +02:00
parent 0ba75aa623
commit 1b83db41e5
3 changed files with 26 additions and 5 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ require_once(dirname(__FILE__)."/../lib/showsleep.php");
require_once(dirname(__FILE__)."/../lib/functions.php");
$version="0.3r1091";
$version="0.3r1092";
$db = new DB();
$functions = new Functions();
+4 -4
View File
@@ -1127,7 +1127,7 @@ class Film
$andYearIn .= $end . ')';
}
$IMDBCheck = $this->db->queryOneRow(
sprintf('%s WHERE title %s %s', $query, $this->db->likeString($this->currentTitle), $andYearIn));
sprintf('%s WHERE title %s %s', $query, $this->functions->likeString($this->currentTitle), $andYearIn));
// Look by %word%word%word% etc..
if ($IMDBCheck === false) {
@@ -1138,7 +1138,7 @@ class Film
}
$IMDBCheck = $this->db->queryOneRow(
sprintf("%s WHERE replace(replace(title, \"'\", ''), '!', '') %s %s",
$query, $this->db->likeString($tempTitle), $andYearIn
$query, $this->functions->likeString($tempTitle), $andYearIn
)
);
}
@@ -1149,7 +1149,7 @@ class Film
if ($tempTitle !== $this->currentTitle) {
$IMDBCheck = $this->db->queryOneRow(
sprintf('%s WHERE title %s %s',
$query, $this->db->likeString($tempTitle), $andYearIn
$query, $this->functions->likeString($tempTitle), $andYearIn
)
);
@@ -1162,7 +1162,7 @@ class Film
}
$IMDBCheck = $this->db->queryOneRow(
sprintf("%s WHERE replace(replace(replace(title, \"'\", ''), '!', ''), '\"', '') %s %s",
$query, $this->db->likeString($tempTitle), $andYearIn
$query, $this->functions->likeString($tempTitle), $andYearIn
)
);
}
+21
View File
@@ -3651,6 +3651,27 @@ class Functions
}
}
/**
* Formats a 'like' string. ex.(LIKE '%chocolate%')
*
* @param string $str The string.
* @param bool $left Add a % to the left.
* @param bool $right Add a % to the right.
*
* @return string
*/
public function likeString($str, $left=true, $right=true)
{
return (
(DB_TYPE === 'mysql' ? 'LIKE ' : 'ILIKE ') .
$this->escapeString(
($left ? '%' : '') .
$str .
($right ? '%' : '')
)
);
}
//end of testing