dbms_primeidc init...1
This commit is contained in:
parent
fc84ba008a
commit
bfe0dd87c7
@ -70,7 +70,7 @@ abstract class Model
|
|||||||
}
|
}
|
||||||
return implode(",", $temps);
|
return implode(",", $temps);
|
||||||
}
|
}
|
||||||
final public function makeQuery(mixed $columns, mixed $values = null, $delimeter = ","): string
|
final public function makeWhere(mixed $columns, mixed $values = null, $delimeter = ","): string
|
||||||
{
|
{
|
||||||
$temps = [];
|
$temps = [];
|
||||||
if (is_array($columns)) {
|
if (is_array($columns)) {
|
||||||
@ -85,9 +85,14 @@ abstract class Model
|
|||||||
// throw new \Exception("DATA:" . $columns . $value === null ? "NULL" : $value);
|
// throw new \Exception("DATA:" . $columns . $value === null ? "NULL" : $value);
|
||||||
return implode($delimeter . " ", $temps);
|
return implode($delimeter . " ", $temps);
|
||||||
}
|
}
|
||||||
|
final public function getWhere(): string
|
||||||
|
{
|
||||||
|
return count($this->_wheres) ? "WHERE " . implode(" ", $this->_wheres) : "";
|
||||||
|
}
|
||||||
|
|
||||||
final public function where(mixed $columns, mixed $values = null, string $delimeter = "AND"): void
|
final public function where(mixed $columns, mixed $values = null, string $delimeter = "AND"): void
|
||||||
{
|
{
|
||||||
$query = $this->makeQuery($columns, $values, $delimeter);
|
$query = $this->makeWhere($columns, $values, $delimeter);
|
||||||
$this->_wheres[] = count($this->_wheres) ? $delimeter . " " . $query : $query;
|
$this->_wheres[] = count($this->_wheres) ? $delimeter . " " . $query : $query;
|
||||||
}
|
}
|
||||||
final public function orWhere(mixed $columns, mixed $values = null, string $delimeter = "OR"): void
|
final public function orWhere(mixed $columns, mixed $values = null, string $delimeter = "OR"): void
|
||||||
@ -96,16 +101,13 @@ abstract class Model
|
|||||||
}
|
}
|
||||||
final public function whereIn(string $column, array $values, string $delimeter = "AND", $range = "IN")
|
final public function whereIn(string $column, array $values, string $delimeter = "AND", $range = "IN")
|
||||||
{
|
{
|
||||||
$this->_wheres[] = "{$delimeter} {$column} {$range} (" . $this->getValue($values) . ")";
|
$query = " {$column} {$range} (" . $this->getValue($values) . ")";
|
||||||
|
$this->_wheres[] = count($this->_wheres) ? $delimeter . " " . $query : $query;
|
||||||
}
|
}
|
||||||
final public function whereNotIn(string $column, array $values, string $delimeter = "AND", $range = "NOT IN")
|
final public function whereNotIn(string $column, array $values, string $delimeter = "AND", $range = "NOT IN")
|
||||||
{
|
{
|
||||||
$this->whereIn($column, $values, $delimeter, $range);
|
$this->whereIn($column, $values, $delimeter, $range);
|
||||||
}
|
}
|
||||||
final public function getWhere(): string
|
|
||||||
{
|
|
||||||
return count($this->_wheres) ? "WHERE " . implode(" ", $this->_wheres) : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
final public function execute(string $query): bool|PDOStatement
|
final public function execute(string $query): bool|PDOStatement
|
||||||
{
|
{
|
||||||
@ -125,12 +127,12 @@ abstract class Model
|
|||||||
//CURD문
|
//CURD문
|
||||||
final protected function create_process(mixed $columns, mixed $values = null): bool|PDOStatement
|
final protected function create_process(mixed $columns, mixed $values = null): bool|PDOStatement
|
||||||
{
|
{
|
||||||
$query = sprintf("INSERT INTO %s VALUES(%s) %s", $this->getTable(), $this->makeQuery($columns, $values), $this->getWhere());
|
$query = sprintf("INSERT INTO %s VALUES(%s) %s", $this->getTable(), $this->makeWhere($columns, $values), $this->getWhere());
|
||||||
return $this->execute($query);
|
return $this->execute($query);
|
||||||
} //
|
} //
|
||||||
final protected function modify_process(mixed $columns, mixed $values = null): bool|PDOStatement
|
final protected function modify_process(mixed $columns, mixed $values = null): bool|PDOStatement
|
||||||
{
|
{
|
||||||
$query = sprintf("UPDATE %s SET %s %s", $this->getTable(), $this->makeQuery($columns, $values), $this->getWhere());
|
$query = sprintf("UPDATE %s SET %s %s", $this->getTable(), $this->makeWhere($columns, $values), $this->getWhere());
|
||||||
return $this->execute($query);
|
return $this->execute($query);
|
||||||
} //
|
} //
|
||||||
final protected function delete_process(): bool|PDOStatement
|
final protected function delete_process(): bool|PDOStatement
|
||||||
@ -160,20 +162,20 @@ abstract class Model
|
|||||||
//Result
|
//Result
|
||||||
protected function getResult($mode = PDO::FETCH_ASSOC): mixed
|
protected function getResult($mode = PDO::FETCH_ASSOC): mixed
|
||||||
{
|
{
|
||||||
$query = "{$this->_querys['SELECT']} FROM {$this->getTable()} {$this->getWhere()} {$this->_querys['JOIN']} {$this->_querys['LIMIT']} {$this->_querys['ORDERBY']}";
|
$query = "{$this->_querys['SELECT']} FROM {$this->getTable()} {$this->_querys['JOIN']} {$this->getWhere()} {$this->_querys['ORDERBY']} {$this->_querys['LIMIT']}";
|
||||||
$stmt = $this->execute($query);
|
$stmt = $this->execute($query);
|
||||||
return $stmt->fetch($mode);
|
return $stmt->fetch($mode);
|
||||||
}
|
}
|
||||||
protected function getResults($mode = PDO::FETCH_ASSOC): mixed
|
protected function getResults($mode = PDO::FETCH_ASSOC): mixed
|
||||||
{
|
{
|
||||||
$query = "{$this->_querys["SELECT"]} FROM {$this->getTable()} {$this->getWhere()} {$this->_querys['JOIN']} {$this->_querys['ORDERBY']} {$this->_querys['LIMIT']}";
|
$query = "{$this->_querys["SELECT"]} FROM {$this->getTable()} {$this->_querys['JOIN']} {$this->getWhere()} {$this->_querys['ORDERBY']} {$this->_querys['LIMIT']}";
|
||||||
$stmt = $this->execute($query);
|
$stmt = $this->execute($query);
|
||||||
return $stmt->fetchAll($mode);
|
return $stmt->fetchAll($mode);
|
||||||
}
|
}
|
||||||
final public function countAllResults(string $column = "*", $reset = true): int
|
final public function countAllResults(string $column = "*", $reset = true): int
|
||||||
{
|
{
|
||||||
$this->_reset = $reset;
|
$this->_reset = $reset;
|
||||||
$query = "SELECT COUNT({$column}) FROM {$this->getTable()} {$this->getWhere()} {$this->_querys['JOIN']}";
|
$query = "SELECT COUNT({$column}) FROM {$this->getTable()} {$this->_querys['JOIN']} {$this->getWhere()}";
|
||||||
$stmt = $this->execute($query);
|
$stmt = $this->execute($query);
|
||||||
$count = $stmt->fetchColumn(0);
|
$count = $stmt->fetchColumn(0);
|
||||||
$this->_reset = true;
|
$this->_reset = true;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user