-
Notifications
You must be signed in to change notification settings - Fork 58
/
Sql.php
109 lines (99 loc) 路 2.51 KB
/
Sql.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
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
<?php namespace ClanCats\Hydrahon\Query;
/**
* SQL query object
**
* @package Hydrahon
* @copyright 2015 Mario D枚ring
*/
use ClanCats\Hydrahon\BaseQuery;
use ClanCats\Hydrahon\Query\Sql\Select;
use ClanCats\Hydrahon\Query\Sql\Insert;
use ClanCats\Hydrahon\Query\Sql\Update;
use ClanCats\Hydrahon\Query\Sql\Delete;
use ClanCats\Hydrahon\Query\Sql\Drop;
use ClanCats\Hydrahon\Query\Sql\Truncate;
use ClanCats\Hydrahon\Query\Sql\Table;
class Sql extends BaseQuery
{
/**
* Create a new table instance
*
* $h->table('users')
*
* @param string|array $fields
* @return Select
*/
public function table($table = null, $alias = null)
{
$query = new Table($this); return $query->table($table, $alias);
}
/**
* Create a new select query builder
*
* $h->select('users', ['name', 'age'])
*
* @param string|array $fields
* @return Select
*/
public function select($table = null, $fields = null)
{
return $this->table($table)->select($fields);
}
/**
* Create a new insert query builder
*
* $h->insert('users', ['name' => 'Lucas', 'age' => 21])
*
* @param array $values
* @return Insert
*/
public function insert($table = null, array $values = array())
{
return $this->table($table)->insert($values);
}
/**
* Create a new update query builder
*
* $h->update('users', ['age' => 25])->where('name', 'Johanna')
*
* @param array $values
* @return Update
*/
public function update($table = null, array $values = array())
{
return $this->table($table)->update($values);
}
/**
* Create a new delete sql builder
*
* $h->delete('users')->where('age', '<', '18')
*
* @return Delete
*/
public function delete($table = null)
{
return $this->table($table)->delete();
}
/**
* Create a new drop table query
*
* $h->drop('users')
*
* @return Drop
*/
public function drop($table = null)
{
return $this->table($table)->drop();
}
/**
* Create a new truncate table query
*
* $h->truncate('users')
*
* @return Truncate
*/
public function truncate($table = null)
{
return $this->table($table)->truncate();
}
}