-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueryInterface.php
More file actions
140 lines (131 loc) · 3.6 KB
/
Copy pathQueryInterface.php
File metadata and controls
140 lines (131 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
namespace Bdf\Prime\Query;
use Bdf\Prime\Collection\CollectionInterface;
use Bdf\Prime\Exception\PrimeException;
use Bdf\Prime\Query\Contract\Compilable;
use Bdf\Prime\Query\Contract\Deletable;
use Bdf\Prime\Query\Contract\Projectionable;
use Bdf\Prime\Query\Contract\ReadOperation;
use Bdf\Prime\Query\Contract\Whereable;
use Bdf\Prime\Query\Contract\WriteOperation;
use Bdf\Prime\Query\Pagination\PaginatorInterface;
use Bdf\Prime\Types\TypeInterface;
/**
* QueryInterface
*
* @template C as \Bdf\Prime\Connection\ConnectionInterface
* @template R as object|array
*
* @extends ReadCommandInterface<C, R>
*/
interface QueryInterface extends ReadCommandInterface, Whereable, Projectionable, Compilable, Deletable
{
/**
* Turns the query being built into a bulk update query that ranges over
* a certain table
*
* <code>
* $query
* ->from('users', 'u')
* ->update(['u.password' => md5('password')]);
* </code>
*
* @param array $data
* @param array $types
*
* @return int The number of updated rows
* @throws PrimeException When execute fail
*/
#[WriteOperation]
public function update(array $data = [], array $types = []): int;
/**
* Set update values
*
* <code>
* $query
* ->from('users', 'u');
* ->where('u.id = ?');
* ->set('u.password', md5('password'), 'string')
* ->update()
* </code>
*
* @param string $column
* @param mixed $value
* @param mixed $type
*
* @return $this This Query instance.
*/
public function set(string $column, $value, $type = null);
/**
* Turns the query being built into an insert query that inserts into
* a certain table
*
* <code>
* $query
* ->from('users')
* ->insert(array(
* 'name' => 'foo',
* 'password' => 'bar'
* ));
* </code>
*
* @param array $data The values to set.
*
* @return int The number of updated rows
* @throws PrimeException When execute fail
*/
#[WriteOperation]
public function insert(array $data = []): int;
/**
* Set insert value
*
* <code>
* $query
* ->from('users')
* ->setValue('name', 'foo', 'string')
* ->setValue('password', 'bar', 'string')
* ->insert();
* </code>
*
* @param string $column
* @param mixed $value
* @param string|TypeInterface|null $type
*
* @return $this
*/
public function setValue(string $column, $value, $type = null);
/**
* Replace values from mapper table
*
* {@see self::insert} for api documentation
*
* @param array $values The values to replace.
*
* @return int The number of updated rows
* @throws PrimeException When execute fail
*/
#[WriteOperation]
public function replace(array $values = []): int;
/**
* Get rows collection
*
* @param array $criteria
* @param string|array $attributes
*
* @return R[]|CollectionInterface<R>|PaginatorInterface<R>
* @throws PrimeException When execute fail
*/
#[ReadOperation]
public function find(array $criteria, $attributes = null);
/**
* Get one row by criteria
*
* @param array $criteria
* @param string|array $attributes
*
* @return R|null
* @throws PrimeException When execute fail
*/
#[ReadOperation]
public function findOne(array $criteria, $attributes = null);
}