get rid of exists(), because rowCount doesn't work consistently
This commit is contained in:
parent
431d6dd523
commit
cb29d07ecc
2 changed files with 1 additions and 16 deletions
|
@ -220,21 +220,6 @@ class Database
|
|||
return $row ? $row : null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute an SQL query and return a boolean based on whether it returns a result
|
||||
*/
|
||||
public function exists(string $query, array $args=[], bool $scoreql = false): bool
|
||||
{
|
||||
if ($scoreql===true) {
|
||||
$query = $this->scoreql_to_sql($query);
|
||||
}
|
||||
$_start = microtime(true);
|
||||
$result = $this->execute($query, $args);
|
||||
$this->count_time("exists", $_start, $query, $args);
|
||||
return $result->rowCount()>0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute an SQL query and return the first column of each row.
|
||||
*/
|
||||
|
|
|
@ -227,7 +227,7 @@ class Favorites extends Extension
|
|||
{
|
||||
global $database;
|
||||
if ($do_set) {
|
||||
if (!$database->exists("select 1 from user_favorites where image_id=:image_id and user_id=:user_id", ["image_id"=>$image_id, "user_id"=>$user_id])) {
|
||||
if (!$database->get_row("select 1 from user_favorites where image_id=:image_id and user_id=:user_id", ["image_id"=>$image_id, "user_id"=>$user_id])) {
|
||||
$database->Execute(
|
||||
"INSERT INTO user_favorites(image_id, user_id, created_at) VALUES(:image_id, :user_id, NOW())",
|
||||
["image_id"=>$image_id, "user_id"=>$user_id]
|
||||
|
|
Reference in a new issue