Skip to content

Commit 90e748b

Browse files
committed
refactor(QueryBuilder): Port away from deprecated execute method
Signed-off-by: Carl Schwan <[email protected]>
1 parent 9fb2f76 commit 90e748b

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

lib/Db/RecipeDb.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function findRecipeById(int $id) {
4343
->where('recipe_id = :id');
4444
$qb->setParameter('id', $id, IQueryBuilder::PARAM_INT);
4545

46-
$cursor = $qb->execute();
46+
$cursor = $qb->executeQuery();
4747
$row = $cursor->fetch();
4848
$cursor->closeCursor();
4949

@@ -67,23 +67,23 @@ public function deleteRecipeById(int $id) {
6767
->where('recipe_id = :id');
6868
$qb->setParameter('id', $id, IQueryBuilder::PARAM_INT);
6969

70-
$qb->execute();
70+
$qb->executeStatement();
7171

7272
$qb = $this->db->getQueryBuilder();
7373

7474
$qb->delete(self::DB_TABLE_KEYWORDS)
7575
->where('recipe_id = :id');
7676
$qb->setParameter('id', $id, IQueryBuilder::PARAM_INT);
7777

78-
$qb->execute();
78+
$qb->executeStatement();
7979

8080
$qb = $this->db->getQueryBuilder();
8181

8282
$qb->delete(self::DB_TABLE_CATEGORIES)
8383
->where('recipe_id = :id');
8484
$qb->setParameter('id', $id, IQueryBuilder::PARAM_INT);
8585

86-
$qb->execute();
86+
$qb->executeStatement();
8787
}
8888

8989
public function findAllRecipes(string $user_id) {
@@ -108,7 +108,7 @@ public function findAllRecipes(string $user_id) {
108108
)
109109
);
110110

111-
$cursor = $qb->execute();
111+
$cursor = $qb->executeQuery();
112112
$result = $cursor->fetchAll();
113113
$cursor->closeCursor();
114114

@@ -173,7 +173,7 @@ public function findAllKeywords(string $user_id) {
173173
->orderBy('k.name');
174174
$qb->setParameter('user', $user_id, Types::STRING);
175175

176-
$cursor = $qb->execute();
176+
$cursor = $qb->executeQuery();
177177
$result = $cursor->fetchAll();
178178
$cursor->closeCursor();
179179

@@ -202,7 +202,7 @@ public function findAllCategories(string $user_id) {
202202
->orderBy('c.name');
203203
$qb->setParameter('user', $user_id, Types::STRING);
204204

205-
$cursor = $qb->execute();
205+
$cursor = $qb->executeQuery();
206206
$result = $cursor->fetchAll();
207207
$cursor->closeCursor();
208208

@@ -230,7 +230,7 @@ public function findAllCategories(string $user_id) {
230230
$qb->expr()->isNull('c.name')
231231
);
232232

233-
$cursor = $qb->execute();
233+
$cursor = $qb->executeQuery();
234234
$row = $cursor->fetch();
235235
$cursor->closeCursor();
236236

@@ -289,7 +289,7 @@ public function getRecipesByCategory(string $category, string $user_id) {
289289
);
290290
}
291291

292-
$cursor = $qb->execute();
292+
$cursor = $qb->executeQuery();
293293
$result = $cursor->fetchAll();
294294
$cursor->closeCursor();
295295

@@ -333,7 +333,7 @@ public function getRecipesByKeywords(string $keywords, string $user_id) {
333333
$qb->groupBy(['r.name', 'r.recipe_id', 'kk.name', 'r.date_created', 'r.date_modified', 'c.name']);
334334
$qb->orderBy('r.name');
335335

336-
$cursor = $qb->execute();
336+
$cursor = $qb->executeQuery();
337337
$result = $cursor->fetchAll();
338338
$cursor->closeCursor();
339339

@@ -388,7 +388,7 @@ public function findRecipes(array $keywords, string $user_id) {
388388
$qb->groupBy(['r.name', 'r.recipe_id', 'kk.name', 'r.date_created', 'r.date_modified', 'c.name']);
389389
$qb->orderBy('r.name');
390390

391-
$cursor = $qb->execute();
391+
$cursor = $qb->executeQuery();
392392
$result = $cursor->fetchAll();
393393
$cursor->closeCursor();
394394

@@ -430,23 +430,23 @@ public function emptySearchIndex(string $user_id) {
430430
->orWhere('user_id = :empty');
431431
$qb->setParameter('user', $user_id, Types::STRING);
432432
$qb->setParameter('empty', 'empty', Types::STRING);
433-
$qb->execute();
433+
$qb->executeStatement();
434434

435435
$qb = $this->db->getQueryBuilder();
436436
$qb->delete(self::DB_TABLE_KEYWORDS)
437437
->where('user_id = :user')
438438
->orWhere('user_id = :empty');
439439
$qb->setParameter('user', $user_id, Types::STRING);
440440
$qb->setParameter('empty', 'empty', Types::STRING);
441-
$qb->execute();
441+
$qb->executeStatement();
442442

443443
$qb = $this->db->getQueryBuilder();
444444
$qb->delete(self::DB_TABLE_CATEGORIES)
445445
->where('user_id = :user')
446446
->orWhere('user_id = :empty');
447447
$qb->setParameter('user', $user_id, Types::STRING);
448448
$qb->setParameter('empty', 'empty', Types::STRING);
449-
$qb->execute();
449+
$qb->executeStatement();
450450
}
451451

452452
private function isRecipeEmpty($json) {
@@ -484,7 +484,7 @@ public function deleteRecipes(array $ids, string $userId) {
484484
));
485485
}
486486

487-
$qb->execute();
487+
$qb->executeStatement();
488488
}
489489

490490
/**
@@ -518,7 +518,7 @@ public function insertRecipes(array $recipes, string $userId) {
518518
$dateModified = $this->parseDate($recipe['dateModified']);
519519
$qb->setParameter('dateModified', $dateModified, Types::DATETIME);
520520

521-
$qb->execute();
521+
$qb->executeStatement();
522522
}
523523
}
524524

@@ -544,7 +544,7 @@ public function updateRecipes(array $recipes, string $userId) {
544544
$qb->setParameter('uid', $userId);
545545

546546
try {
547-
$qb->execute();
547+
$qb->executeStatement();
548548
} catch (\Exception $ex) {
549549
throw $ex;
550550
}
@@ -561,7 +561,7 @@ public function getKeywordsOfRecipe(int $recipeId, string $userId) {
561561
$qb->setParameter('rid', $recipeId);
562562
$qb->setParameter('uid', $userId);
563563

564-
$cursor = $qb->execute();
564+
$cursor = $qb->executeQuery();
565565
$result = $cursor->fetchAll();
566566
$cursor->closeCursor();
567567

@@ -583,7 +583,7 @@ public function getCategoryOfRecipe(int $recipeId, string $userId) {
583583
$qb->setParameter('rid', $recipeId);
584584
$qb->setParameter('uid', $userId);
585585

586-
$cursor = $qb->execute();
586+
$cursor = $qb->executeQuery();
587587
$result = $cursor->fetch();
588588
$cursor->closeCursor();
589589

@@ -601,7 +601,7 @@ public function updateCategoryOfRecipe(int $recipeId, string $categoryName, stri
601601
$qb->set('name', $qb->createNamedParameter($categoryName, IQueryBuilder::PARAM_STR));
602602
$qb->setParameter('rid', $recipeId, Types::INTEGER);
603603
$qb->setParameter('user', $userId, Types::STRING);
604-
$qb->execute();
604+
$qb->executeStatement();
605605
}
606606

607607
public function addCategoryOfRecipe(int $recipeId, string $categoryName, string $userId) {
@@ -623,7 +623,7 @@ public function addCategoryOfRecipe(int $recipeId, string $categoryName, string
623623
$qb->setParameter('user', $userId, Types::STRING);
624624

625625
try {
626-
$qb->execute();
626+
$qb->executeStatement();
627627
} catch (\Exception $e) {
628628
// Category didn't meet restrictions, skip it
629629
}
@@ -635,7 +635,7 @@ public function removeCategoryOfRecipe(int $recipeId, string $userId) {
635635
->where('recipe_id = :rid', 'user_id = :user');
636636
$qb->setParameter('rid', $recipeId, Types::INTEGER);
637637
$qb->setParameter('user', $userId, Types::STRING);
638-
$qb->execute();
638+
$qb->executeStatement();
639639
}
640640

641641
public function addKeywordPairs(array $pairs, string $userId) {
@@ -653,9 +653,9 @@ public function addKeywordPairs(array $pairs, string $userId) {
653653
$qb->setParameter('name', $p['name'], Types::STRING);
654654

655655
try {
656-
$qb->execute();
656+
$qb->executeStatement();
657657
} catch (\Exception $ex) {
658-
// The insertion of a keywaord might conflict with the requirements. Skip it.
658+
// The insertion of a keyword might conflict with the requirements. Skip it.
659659
}
660660
}
661661
}
@@ -678,7 +678,7 @@ public function removeKeywordPairs(array $pairs, string $userId) {
678678
);
679679
}
680680

681-
$qb->execute();
681+
$qb->executeStatement();
682682
}
683683

684684
private function parseDate(?string $date) {

lib/Migration/Version000000Date20210701093123.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array
3838
->having('COUNT(*) > 1');
3939
//echo $qb->getSQL() . "\n";
4040

41-
$cursor = $qb->execute();
41+
$cursor = $qb->executeQuery();
4242
$result = $cursor->fetchAll();
4343

4444
if (sizeof($result) > 0) {
@@ -66,10 +66,10 @@ public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array
6666
foreach ($result as $r) {
6767
$qb->setParameter('user', $r['user']);
6868
$qb->setParameter('recipe', $r['recipe']);
69-
$qb->execute();
69+
$qb->executeStatement();
7070

7171
$qb2->setParameter('user', $r['user']);
72-
$qb2->execute();
72+
$qb2->executeStatement();
7373
}
7474
}
7575

0 commit comments

Comments
 (0)