Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d961d2a80f |
@@ -12,22 +12,32 @@ class Model implements JsonSerializable
|
||||
protected string $connection = "";
|
||||
protected string $pk;
|
||||
private bool $new;
|
||||
private bool $ro;
|
||||
|
||||
public function __construct()
|
||||
public function __construct($ro = false)
|
||||
{
|
||||
$this->new = true;
|
||||
$this->values = array();
|
||||
$this->updated = array();
|
||||
$this->pk = "id";
|
||||
$this->ro = $ro;
|
||||
$this->initTable();
|
||||
}
|
||||
|
||||
private function initTable(): void
|
||||
{
|
||||
if(!$this->ro)
|
||||
{
|
||||
if ($this->table == "") {
|
||||
$this->table = $this->getDefaultTableName();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->table = "ReadOnlyModel";
|
||||
$this->pk = "__idpk";
|
||||
}
|
||||
}
|
||||
|
||||
public function getTable(): string
|
||||
{
|
||||
@@ -89,6 +99,8 @@ class Model implements JsonSerializable
|
||||
public function save(): bool
|
||||
{
|
||||
$ret = false;
|
||||
if(!$this->ro)
|
||||
{
|
||||
$qb = $this->newQueryBuilder();
|
||||
if ($this->new) {
|
||||
$query = $qb->getPreparedQuery($this->values);
|
||||
@@ -114,6 +126,7 @@ class Model implements JsonSerializable
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user