ADD считаю кол-во переходов по сокращённой ссылке

This commit is contained in:
Krivchikov Dmitry 2016-05-05 23:52:42 +03:00
parent 716e4d394b
commit 90d96afb2b
2 changed files with 17 additions and 0 deletions

View File

@ -318,4 +318,20 @@ abstract class Model
return (int)$row['cnt'];
}
function update(array $fields)
{
if (empty($fields)) {
return FALSE;
}
$request = App::DB()->prepare('UPDATE ' . $this->_tableName_ . ' SET `' . implode('`=?, `', array_keys($fields)) . '`=? WHERE ' . $this->_primaryKey_ . '=' . $this->_id_);
$res = $request->execute(array_values($fields));
if ($res)
{
return $this->getByPK($this->_id_);
}
return FALSE;
}
}

View File

@ -8,6 +8,7 @@ class SController extends Controller
$shortUrl = ShortUrl::model()->getByPK($key);
if($shortUrl->id) {
$shortUrl->update(array('views' => intval($shortUrl->views + 1)));
App::redirect($shortUrl->url);
} else {
App::error404();