PHP Developers Network
http://forums.devnetwork.net/

How to update record in bolt CMS ??
http://forums.devnetwork.net/viewtopic.php?f=72&t=143139
Page 1 of 1

Author:  gautamz07 [ Tue Nov 15, 2016 5:17 pm ]
Post subject:  How to update record in bolt CMS ??

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:

Syntax: [ Download ] [ Hide ]
   $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 ??

Author:  Celauran [ Tue Nov 15, 2016 5:25 pm ]
Post subject:  Re: How to update record in bolt CMS ??

Start here: https://docs.bolt.cm/3.2/internals/cont ... ces#app-db

Author:  gautamz07 [ Tue Nov 15, 2016 6:06 pm ]
Post subject:  Re: How to update record in bolt CMS ??

Celauran ! Awesome .. thanks aloot :)

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/