Answer the question
In order to leave comments, you need to log in
How to get WHERE pages correctly?
Hello.
There is an abstract class whose code is:
...
public static function updateViews(): array{
$db = Db::getInstance();
return $db->query('UPDATE `' . static::getTableName() . '` SET `views` = `views` +1', [], static::class);
}
public static function getByUrl(string $url): ?self{
$db = Db::getInstance();
$entities = $db->query(
'SELECT * FROM `' . static::getTableName() . '` WHERE url=:url' ,
[':url' => $url],
static::class
);
return $entities ? $entities[0] : null;
}
public function view(string $articleUrl){
$article = Article::getByUrl($articleUrl);
$updateViews = Article::updateViews();
return $db->query('UPDATE `' . static::getTableName() . '` SET `views` = `views` +1 WHERE id = 1', [], static::class);
Answer the question
In order to leave comments, you need to log in
You would not climb into abstract classes yet.
And if on the topic, then after all, you have already been explained 5 times how to use your own database class
$sql = 'UPDATE `' . static::getTableName() . '` SET `views` = `views` +1 WHERE id=?';
return $db->query($sql, [$article->id]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question