mirror of
https://github.com/openvk/chandler.git
synced 2025-02-23 20:19:43 +03:00
35 lines
741 B
PHP
35 lines
741 B
PHP
|
<?php declare(strict_types=1);
|
||
|
namespace Chandler\Patterns;
|
||
|
use Chandler\Database\DatabaseConnection;
|
||
|
|
||
|
class ActiveRecord
|
||
|
{
|
||
|
private $db; #DB
|
||
|
|
||
|
private $table; #DATA
|
||
|
private $query;
|
||
|
private $row;
|
||
|
private $changes = [];
|
||
|
|
||
|
protected $tableName;
|
||
|
protected $primaryKey = "id";
|
||
|
protected $timestamps = true;
|
||
|
protected $softDelete = true;
|
||
|
|
||
|
function __construct()
|
||
|
{
|
||
|
$this->db = DatabaseConnection::i();
|
||
|
$this->table = $this->db->table($this->tableName);
|
||
|
if(!is_null($row)) $this->row = $row;
|
||
|
|
||
|
$this->resetQuery();
|
||
|
}
|
||
|
|
||
|
private function resetQuery(): void
|
||
|
{
|
||
|
$this->query = clone $this->table;
|
||
|
}
|
||
|
|
||
|
function __call()
|
||
|
}
|