-
Notifications
You must be signed in to change notification settings - Fork 27
/
QueryFactory.php
37 lines (31 loc) · 1.35 KB
/
QueryFactory.php
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
<?php
declare(strict_types=1);
namespace TheCodingMachine\TDBM\QueryFactory;
use TheCodingMachine\TDBM\UncheckedOrderBy;
/**
* Classes implementing this interface can generate SQL and SQL count queries to be used by result iterators.
*/
interface QueryFactory
{
/**
* Sets the ORDER BY directive executed in SQL.
*
* For instance:
*
* $queryFactory->sort('label ASC, status DESC');
*
* **Important:** TDBM does its best to protect you from SQL injection. In particular, it will only allow column names in the "ORDER BY" clause. This means you are safe to pass input from the user directly in the ORDER BY parameter.
* If you want to pass an expression to the ORDER BY clause, you will need to tell TDBM to stop checking for SQL injections. You do this by passing a `UncheckedOrderBy` object as a parameter:
*
* $queryFactory->sort(new UncheckedOrderBy('RAND()'))
*
* @param string|UncheckedOrderBy|null $orderBy
*/
public function sort($orderBy): void;
public function getMagicSql() : string;
public function getMagicSqlCount() : string;
/**
* @return mixed[][] An array of column descriptors. The key might be in the form "$tableName____$columnName". Value is an array with those keys: as, table, column, type, tableGroup
*/
public function getColumnDescriptors() : array;
}