Skip to content

Commit e87a781

Browse files
committed
new methos added, exists and fetch
1 parent d67edb8 commit e87a781

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

core/model/Model.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ abstract class Model extends Database
1212
private $sql;
1313
private $where;
1414
private $fields;
15-
public $count;
15+
private $count;
16+
private $fetch;
1617

1718
public function __construct()
1819
{
@@ -148,6 +149,20 @@ public function findById($id)
148149
return self::findOne([$this->pk => $id]);
149150
}
150151

152+
public function exists($id)
153+
{
154+
if (is_array($id)) {
155+
return (self::findOne($id));
156+
}
157+
158+
return (self::findById($id));
159+
}
160+
161+
public function fetch()
162+
{
163+
return $this->fetch;
164+
}
165+
151166
public function query($sql)
152167
{
153168
$this->stmt = $this->conn->prepare($sql);

0 commit comments

Comments
 (0)