Update PreferenceMapper.php

This commit is contained in:
fcki1984 2023-05-12 21:20:20 +08:00 committed by GitHub
parent 3ea424693b
commit 4798977aea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,7 @@
namespace OCA\Epubreader\Db; namespace OCA\Epubreader\Db;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCA\Epubreader\Utility\Time; use OCA\Epubreader\Utility\Time;
use OCP\IDBConnection; use OCP\IDBConnection;
@ -29,22 +30,22 @@ class PreferenceMapper extends ReaderMapper {
* @return array * @return array
*/ */
public function get($scope, $fileId, $name=null) { public function get($scope, $fileId, $name=null) {
if(!empty($name)) { $query = $this->db->getQueryBuilder();
$sql = "SELECT * FROM `*PREFIX*reader_prefs` WHERE `scope`=? AND `file_id`=? AND `user_id`=? AND `name`=?"; $query->select('*')
$args = array( ->from($this->getTableName())
$scope, ->where($query->expr()->eq('scope', $query->createNamedParameter($scope)))
$fileId, ->andWhere($query->expr()->eq('file_id', $query->createNamedParameter($fileId)))
$this->userId, ->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($this->userId)));
$name);
} else { if (!empty($name)) {
$sql = "SELECT * FROM `*PREFIX*reader_prefs` WHERE `scope`=? AND `file_id`=? AND `user_id`=?"; $query->andWhere($query->expr()->eq('name', $query->createNamedParameter($name)));
$args = array(
$scope,
$fileId,
$this->userId);
} }
return $this->findEntities($sql, $args); return $this->findEntities($query);
} }
/** /**