dimanche 19 avril 2015

sqlite row data increment in laravel

Using Laravel and sqlite I'm trying to increment a value that represents how many comments are on the next page. The problem I'm having is the value that needs to be incremented is in a button as the "label" so I can't pull the value from it using Input::get('commentCounter').


Here are the functions that are called when I delete and post a comment:



function commentcountdelete($id){
$commentcounter = Input::get('commentcounter');
$sql = "Update status Set commentCount = ?-1 WHERE id = ?";
$results = DB::update ($sql, array($commentcounter,$id));
return $results;
}

function commentcountIncrement($id){
$commentcounter = Input::get('commentcounter');
$sql = "Update status Set commentCount = ?+1 WHERE id = ?";
$results = DB::update ($sql, array($commentcounter,$id));
return $results;
}


Here's where the value needs to be extracted from:



<a href ="{{{ url("comments_post/$post->Id") }}}"><button id="commentBTN" type="button" class="btn btn-default">Comments: {{{$post->commentCount}}}</button></a>

Aucun commentaire:

Enregistrer un commentaire