Page 1 of 1

How to update record in bolt CMS ??

Posted: Tue Nov 15, 2016 4:17 pm
by gautamz07
In my records.twig file i have this variable record ... which has a property views , now views is of integer type in the database , With a default value of 0 , Now everytime the record.twig template is loaded , i want to update the value of the views property in the database. How do i do this in bolt ?? So the update statement will be something like:

Update the views property ... where the ID is equal to the current record ID.

Now ofcouse i can do some hardcording like the following:

Code: Select all

   $db = new PDO('mysql:host=localhost;dbname=peckinga_tinyblog', 'peckinga_general', 'gautam');  
   // Update views
   $query = "UPDATE tinyblog SET views = views + 1 WHERE id = :views_id";
   $stmt = $db->prepare($query);
   $stmt->execute(array(":views_id"=>$article_id));
But is there a bolt specific way of doing this or a more efficient way ??

Re: How to update record in bolt CMS ??

Posted: Tue Nov 15, 2016 4:25 pm
by Celauran

Re: How to update record in bolt CMS ??

Posted: Tue Nov 15, 2016 5:06 pm
by gautamz07
Celauran ! Awesome .. thanks aloot :)