FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
SuperSQL/SuperSQL/SuperSQL.php at master · ThreeLetters/SuperSQL · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
ThreeLetters
/
SuperSQL
Public
Notifications
You must be signed in to change notification settings
Fork
5
Star
15
Code
Issues
0
Pull requests
1
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
SuperSQL
/
SuperSQL
/
SuperSQL.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
156 lines (151 loc) · 4.49 KB
Breadcrumbs
SuperSQL
/
SuperSQL
/
SuperSQL.php
Copy path
File metadata and controls
156 lines (151 loc) · 4.49 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
/*
MIT License
Copyright (c) 2017 Andrew S (Andrews54757_at_gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
namespace
SuperSQL
;
use
SuperSQL
\
lib
\
Parser
as
Parser
;
use
SuperSQL
\
lib
\
SQLConnector
as
SQLConnector
;
// BUILD BETWEEN
class
SuperSQL
{
public
$
con
;
/**
* Creates a connection
* @param {String} dsn - DSN of the connection
* @param {String} user - Username
* @param {String} pass - Password
*/
function
__construct
(
$
dsn
,
$
user
,
$
pass
)
{
$
this
->
con
=
new
SQLConnector
(
$
dsn
,
$
user
,
$
pass
);
}
/**
* Queries a SQL table (SELECT)
*
* @param {String} table - SQL Table
* @param {Array} columns - Columns to return
* @param {Object|Array} where - Where clause
* @param {Object|null} join - Join clause
* @param {String} limit - Limit clause
*
* @returns {SQLResponse|SQLResponse[]}
*/
function
SELECT
(
$
table
,
$
columns
=
array
(),
$
where
=
array
(),
$
join
=
null
,
$
limit
=
false
)
{
if
(!
$
limit
&&
$
join
&& (
isset
(
$
join
[
'
ORDER
'
]) ||
isset
(
$
join
[
'
!ORDER
'
]) ||
isset
(
$
join
[
'
GROUP
'
]) ||
isset
(
$
join
[
'
LIMIT
'
]) ||
isset
(
$
join
[
'
OFFSET
'
]) ||
is_int
(
$
join
) ||
is_string
(
$
join
) ||
isset
(
$
join
[
0
]))) {
$
limit
=
$
join
;
$
join
=
null
;
}
$
d
= Parser::
SELECT
(
$
table
,
$
columns
,
$
where
,
$
join
,
$
limit
);
return
$
this
->
con
->
_query
(
$
d
[
0
],
$
d
[
1
],
$
d
[
2
],
$
d
[
3
],
1
);
}
/**
* Inserts data into a SQL table
*
* @param {String} table - SQL Table
* @param {Object|Array} data - Data to insert
*
* @returns {SQLResponse|SQLResponse[]}
*/
function
INSERT
(
$
table
,
$
data
,
$
append
=
null
)
{
$
d
= Parser::
INSERT
(
$
table
,
$
data
,
$
append
);
return
$
this
->
con
->
_query
(
$
d
[
0
],
$
d
[
1
],
$
d
[
2
]);
}
/**
* Updates a SQL table
*
* @param {String} table - SQL Table
* @param {Object|Array} data - Data to update
* @param {Object|Array} where - Where clause
*
* @returns {SQLResponse|SQLResponse[]}
*/
function
UPDATE
(
$
table
,
$
data
,
$
where
=
array
())
{
$
d
= Parser::
UPDATE
(
$
table
,
$
data
,
$
where
);
return
$
this
->
con
->
_query
(
$
d
[
0
],
$
d
[
1
],
$
d
[
2
]);
}
/**
* Deletes from a SQL table
*
* @param {String} table - SQL Table
* @param {Object|Array} where - Where clause
*
* @returns {SQLResponse|SQLResponse[]}
*/
function
DELETE
(
$
table
,
$
where
=
array
())
{
$
d
= Parser::
DELETE
(
$
table
,
$
where
);
return
$
this
->
con
->
_query
(
$
d
[
0
],
$
d
[
1
],
$
d
[
2
]);
}
/**
* Query
*/
function
query
(
$
query
,
$
obj
=
null
,
$
outtypes
=
null
,
$
mode
=
0
)
{
return
$
this
->
con
->
query
(
$
query
,
$
obj
,
$
outtypes
,
$
mode
);
}
/**
* Closes the connection
*/
function
close
()
{
$
this
->
con
->
close
();
}
/**
* Turns on dev mode
*/
function
dev
()
{
$
this
->
con
->
dev
=
true
;
}
/**
* Get log
*/
function
getLog
()
{
return
$
this
->
con
->
log
;
}
/**
* Transaction
*/
function
transact
(
$
func
)
{
$
this
->
con
->
db
->
beginTransaction
();
try
{
$
r
=
$
func
(
$
this
);
}
catch
(
\
Exception
$
e
) {
$
this
->
con
->
db
->
rollBack
();
return
false
;
}
if
(
$
r
===
false
)
$
this
->
con
->
db
->
rollBack
();
else
$
this
->
con
->
db
->
commit
();
return
$
r
;
}
}
// BUILD BETWEEN
?>
Back
|
FazBrowse Home
|
New Git URL