The SQL error means your MySQL connection was refused.
You should be using models to do this, you are all calling a fetch and doing an update,
/models/YourTable.php
<?php
class YourTable extends \Phalcon\Mvc\Model
{
public function initialize()
{
$this->setSource("your_table_name");
}
}
/controllers/YourController.php
<?php
...
public function indexAction() {
// Find a record by the itemId (Not sure how you are getting it)
$record = YourTable::findById($itemId);
// Increment that record ID
++$record->views;
// Save it
$record->save();
// To see the update:
echo $record->views;
die;
}