This repository has been archived on 2018-05-28. You can view files and clone it, but cannot push or open issues or pull requests.
BBB-Simple-ACS/server/src/Model/Misc/Base.php

40 lines
1007 B
PHP

<?php
namespace acs\Model;
use Acast\Http\Model;
class Base extends Model
{
function __construct()
{
$this->table('client');
}
function fetchById($id)
{
return $this->_select(['`key`', 'token', 'stunum', 'UNIX_TIMESTAMP(updated) AS updated'],
'id='.$id, null, null, null, self::ROW);
}
function fetchByToken($token)
{
if (empty($token))
return false;
return $this->_select(['id', '`key`', 'stunum', 'UNIX_TIMESTAMP(updated) AS updated'],
'token=:t', ['t' => $token], null, null, self::ROW);
}
function updateToken($id, $token)
{
return $this->_update(['token', 'stunum'], 'id='.$id, ['token' => $token, 'stunum' => ''], 1);
}
function updateStunum($token, $stunum)
{
if (empty($token))
return 0;
return $this->_update(['stunum'], ['token=:t', 'stunum=\'\''], [
't' => $token,
'stunum' => $stunum
], 1);
}
}