Completed
Push — master ( 0eeb04...4002ae )
by Oscar
02:31
created

Query::__toString()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 1
nc 1
1
<?php
2
3
namespace SimpleCrud\Queries;
4
5
use SimpleCrud\Table;
6
7
/**
8
 * Base class used by all queries.
9
 */
10
abstract class Query
11
{
12
    protected $table;
13
14
    /**
15
     * Constructor.
16
     *
17
     * @param Table $table
18
     */
19
    public function __construct(Table $table)
20
    {
21
        $this->table = $table;
22
    }
23
24
    /**
25
     * Run the query and return the statement object.
26
     *
27
     * @return PDOStatement
28
     */
29
    abstract public function __invoke();
30
31
    /**
32
     * Build and return the query.
33
     *
34
     * @return string
35
     */
36
    abstract public function __toString();
37
38
    /**
39
     * Executes the query and returns true if it's ok.
40
     * 
41
     * @return mixed
42
     */
43
    public function run()
44
    {
45
        return $this->__invoke();
46
    }
47
}
48