$where = $updateQb->expr()->andX();
$whereValues = array_merge($keys, $updatePreconditionValues);
foreach ($whereValues as $name => $value) {
- $where->add($updateQb->expr()->eq(
- $name,
- $updateQb->createNamedParameter($value, $this->getType($value)),
- $this->getType($value)
- ));
+ if ($value === '') {
+ $where->add($updateQb->expr()->emptyString(
+ $name
+ ));
+ } else {
+ $where->add($updateQb->expr()->eq(
+ $name,
+ $updateQb->createNamedParameter($value, $this->getType($value)),
+ $this->getType($value)
+ ));
+ }
}
$updateQb->where($where);
$affected = $updateQb->execute();
$qb = $this->dbConnection->getQueryBuilder();
$qb->select('credentials')
->from(self::DB_TABLE)
- ->where($qb->expr()->eq('user', $qb->createNamedParameter((string)$userId)))
- ->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier)))
- ;
+ ->where($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier)));
+
+ if ($userId === '') {
+ $qb->andWhere($qb->expr()->emptyString('user'));
+ } else {
+ $qb->andWhere($qb->expr()->eq('user', $qb->createNamedParameter((string)$userId)));
+ }
$qResult = $qb->execute();
$result = $qResult->fetch();
public function delete($userId, $identifier) {
$qb = $this->dbConnection->getQueryBuilder();
$qb->delete(self::DB_TABLE)
- ->where($qb->expr()->eq('user', $qb->createNamedParameter((string)$userId)))
- ->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier)))
- ;
+ ->where($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier)));
+
+ if ($userId === '') {
+ $qb->andWhere($qb->expr()->emptyString('user'));
+ } else {
+ $qb->andWhere($qb->expr()->eq('user', $qb->createNamedParameter((string)$userId)));
+ }
+
return $qb->execute();
}