Refactor database session driver.
This commit is contained in:
parent
89239abd9e
commit
1e57baf923
|
@ -10,7 +10,7 @@ class DB implements \System\Session\Driver {
|
||||||
*/
|
*/
|
||||||
public function load($id)
|
public function load($id)
|
||||||
{
|
{
|
||||||
$session = $this->query()->find($id);
|
$session = $this->table()->find($id);
|
||||||
|
|
||||||
if ( ! is_null($session))
|
if ( ! is_null($session))
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ public function load($id)
|
||||||
public function save($session)
|
public function save($session)
|
||||||
{
|
{
|
||||||
$this->delete($session['id']);
|
$this->delete($session['id']);
|
||||||
$this->query()->insert(array('id' => $session['id'], 'last_activity' => $session['last_activity'], 'data' => serialize($session['data'])));
|
$this->table()->insert(array('id' => $session['id'], 'last_activity' => $session['last_activity'], 'data' => serialize($session['data'])));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,7 +38,7 @@ public function save($session)
|
||||||
*/
|
*/
|
||||||
public function delete($id)
|
public function delete($id)
|
||||||
{
|
{
|
||||||
$this->query()->where('id', '=', $id)->delete();
|
$this->table()->delete($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,7 +49,7 @@ public function delete($id)
|
||||||
*/
|
*/
|
||||||
public function sweep($expiration)
|
public function sweep($expiration)
|
||||||
{
|
{
|
||||||
$this->query()->where('last_activity', '<', $expiration)->delete();
|
$this->table()->where('last_activity', '<', $expiration)->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,7 +57,7 @@ public function sweep($expiration)
|
||||||
*
|
*
|
||||||
* @return Query
|
* @return Query
|
||||||
*/
|
*/
|
||||||
private function query()
|
private function table()
|
||||||
{
|
{
|
||||||
return \System\DB::table(\System\Config::get('session.table'));
|
return \System\DB::table(\System\Config::get('session.table'));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue