Reduce the sql request
This commit is contained in:
parent
39d4be9eb3
commit
dbf62c88bd
1 changed files with 2 additions and 11 deletions
13
db.php
13
db.php
|
@ -95,20 +95,11 @@ class DataBase
|
||||||
while($data = $stmt->fetch()) {
|
while($data = $stmt->fetch()) {
|
||||||
if ($this->areWordsSimilar($data['word'], $word)) {
|
if ($this->areWordsSimilar($data['word'], $word)) {
|
||||||
$word = $data['word'];
|
$word = $data['word'];
|
||||||
|
$wordId = $data['id_word'];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$stmt = $this->db->prepare("
|
if (isset($wordId)) {
|
||||||
SELECT *
|
|
||||||
FROM words
|
|
||||||
WHERE cloud_id = :cid
|
|
||||||
AND word = :w;
|
|
||||||
");
|
|
||||||
$stmt->bindValue(':cid', $cloudId, PDO::PARAM_INT);
|
|
||||||
$stmt->bindValue(':w', $word, PDO::PARAM_STR);
|
|
||||||
$stmt->execute();
|
|
||||||
if ($data = $stmt->fetch()) {
|
|
||||||
$wordId = $data['id_word'];
|
|
||||||
$stmt = $this->db->prepare("
|
$stmt = $this->db->prepare("
|
||||||
UPDATE words
|
UPDATE words
|
||||||
SET count = count + 1
|
SET count = count + 1
|
||||||
|
|
Loading…
Reference in a new issue