mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-07 16:06:15 +00:00
Migrate one function to the new querybuilder for NC 14
This commit is contained in:
parent
80d025d023
commit
25eb211440
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace OCA\OcSms\Db;
|
namespace OCA\OcSms\Db;
|
||||||
|
|
||||||
|
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||||
use \OCP\IDBConnection;
|
use \OCP\IDBConnection;
|
||||||
|
|
||||||
use \OCP\AppFramework\Db\Mapper;
|
use \OCP\AppFramework\Db\Mapper;
|
||||||
@ -57,19 +58,31 @@ class ConfigMapper extends Mapper {
|
|||||||
return true;
|
return true;
|
||||||
} catch (DoesNotExistException $e){
|
} catch (DoesNotExistException $e){
|
||||||
return false;
|
return false;
|
||||||
|
} catch (MultipleObjectsReturnedException $e) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getKey ($key) {
|
public function getKey ($key) {
|
||||||
try {
|
try {
|
||||||
$query = \OCP\DB::prepare("SELECT `value` FROM `*PREFIX*ocsms_config` WHERE `key` = ? AND `user` = ?");
|
$qb = $this->db->getQueryBuilder();
|
||||||
$result = $query->execute(array($key, $this->user));
|
$qb->select('value')
|
||||||
while($row = $result->fetchRow()) {
|
->from('ocsms_config')
|
||||||
|
->where(
|
||||||
|
$qb->expr()->andX(
|
||||||
|
$qb->expr()->eq('key', $qb->createNamedParameter($key)),
|
||||||
|
$qb->expr()->eq('user', $qb->createNamedParameter($this->user))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$result = $qb->execute();
|
||||||
|
if ($row = $result->fetch()) {
|
||||||
return $this->crypto->decrypt($row["value"]);
|
return $this->crypto->decrypt($row["value"]);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} catch (DoesNotExistException $e){
|
} catch (DoesNotExistException $e){
|
||||||
return false;
|
return false;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user