1. Go to this page and download the library: Download flashytime/db-cache library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
flashytime / db-cache example snippets
class TestModel
{
public $dbCache;
public function __construct()
{
// you can get the config in your own way
$config = $this->getConfig();
$this->dbCache = new \Flashytime\DbCache\DbCache($config, 'Test', ['name' => 'test', 'primary' => 'id']);
}
public function create($data)
{
return $this->dbCache->insert($data);
}
public function getById($id)
{
return $this->dbCache->select(['where' => 'id = :id'], ['id' => $id]);
}
public function findAll($offset, $limit)
{
return $this->dbCache->all(['limit' => ':offset, :limit', 'order' => 'id DESC'], ['offset' => $offset, 'limit' => $limit]);
}
public function updateById($id, $data)
{
return $this->dbCache->update(['where' => 'id = :id'], ['id' => $id], $data);
}
public function remove($id)
{
return $this->dbCache->delete(['where' => 'id = :id'], ['id' => $id]);
}
public function getConfig()
{
//path to your config directory
return
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.