update views+1 doesn't work |
I need to update counter views:
In Controller: PHP Code: public function show(string $slug) In Modal: PHP Code: class PostModel extends Model In action views table didn't update and show always 0. How do can I fix this problem?
Set the third parameter in the set() method to false.
https://codeigniter.com/user_guide/datab...ating-data ps: Don't use QueryBuilder in the controller. This is bad practice.
if I add FALSE I see this error:
Code: mysqli_sql_exception #1064 you right! my code just for try. Quote:ps: Don't use QueryBuilder in the controller. This is bad practice.
Hi, try using "increment" method:
PHP Code: $this->postModel->where('id', $post->id)->increment('views'); https://codeigniter.com/user_guide/datab...#increment (01-28-2021, 06:50 AM)nicojmb Wrote: Hi, try using "increment" method: Hello! thanks working now. |
Welcome Guest, Not a member yet? Register Sign In |