Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7309dc6

Browse files
Created few absstarct methods, created CURD nd database methods
1 parent a45d667 commit 7309dc6

File tree

1 file changed

+45
-18
lines changed

1 file changed

+45
-18
lines changed

‎src/Database/QueryBuilder.php‎

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class QueryBuilder
2626
const DML_TYPE_UPDATE = 'UPDATE';
2727
const DML_TYPE_DELETE = 'DELETE';
2828

29-
public $query;
3029

3130
public function __construct(DatabaseConnectionInterface $connection)
3231
{
@@ -50,18 +49,54 @@ public function where($column, $operator = self::OPERATORS[0], $value = null)
5049
}
5150
}
5251
$this->passWhere([$column => $value], $operator);
53-
$this->query = $this->getQuery($this->operation);
54-
52+
$query = $this->prepare($this->getQuery($this->operation));
53+
$this->statement = $this->execute($query);
5554
return $this;
5655
}
5756

57+
//---------------------------------- CURD & Database Methods ---------------------------------------//
58+
5859
public function select(string $fields = self::COLUMNS)
5960
{
6061
$this->operation = self::DML_TYPE_SELECT;
6162
$this->fields = $fields;
6263
return $this;
6364
}
6465

66+
public function create(array $data)
67+
{
68+
69+
}
70+
71+
public function update(array $data)
72+
{
73+
74+
}
75+
76+
public function delete()
77+
{
78+
79+
}
80+
81+
public function raw($query)
82+
{
83+
84+
}
85+
86+
public function find($id)
87+
{
88+
89+
}
90+
91+
public function findOneBy(string $field, $value)
92+
{
93+
94+
}
95+
96+
public function first()
97+
{
98+
99+
}
65100

66101

67102
//----------------------------------------------- Internals Methods -----------------------------------//
@@ -75,21 +110,13 @@ private function passWhere(array $conditions, string $operator)
75110
return $this;
76111
}
77112

78-
/**
79-
* @return mixed
80-
*/
81-
public function getPlaceholders()
82-
{
83-
return $this->placeholders;
84-
}
85-
86-
/**
87-
* @return mixed
88-
*/
89-
public function getBindings()
90-
{
91-
return $this->bindings;
92-
}
113+
//----------------------------------------------- Abstract Methods -----------------------------------//
114+
abstract public function get();
115+
abstract public function count();
116+
abstract public function lastInsertedId();
117+
abstract public function prepare($query);
118+
abstract public function execute($statement);
119+
abstract public function fetchInto($className);
93120

94121

95122
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /