Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
X Lib
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
XLibs
X Lib
Commits
c38d9a32
Commit
c38d9a32
authored
Jun 21, 2016
by
Alex Ne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Добавок к запросам
parent
33d89c01
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
TableItem.php
DB/TableItem.php
+17
-3
No files found.
DB/TableItem.php
View file @
c38d9a32
...
@@ -5,6 +5,8 @@ class TableItem
...
@@ -5,6 +5,8 @@ class TableItem
protected
$table_name
;
protected
$table_name
;
protected
$sql
=
""
;
protected
$sql
=
""
;
protected
$sql_where
=
""
;
protected
$sql_where
=
""
;
protected
$sql_order
=
""
;
protected
$sql_limit
=
""
;
protected
$sql_type
;
protected
$sql_type
;
protected
$driver
=
null
;
protected
$driver
=
null
;
function
__construct
(
$name
,
$driver
)
function
__construct
(
$name
,
$driver
)
...
@@ -240,6 +242,18 @@ class TableItem
...
@@ -240,6 +242,18 @@ class TableItem
return
implode
(
' '
,
$wheres
);
return
implode
(
' '
,
$wheres
);
}
}
public
function
order
(
$coll
,
$type
)
{
$this
->
sql_order
=
" OREDR BY `
{
$coll
}
`
{
$type
}
"
;
return
$this
;
}
public
function
limit
(
$op1
,
$op2
=
false
);
{
if
(
$op2
)
$this
->
sql_limit
=
" LIMIT
{
$op1
}
,
{
$op2
}
"
;
else
$this
->
sql_limit
=
" LIMIT
{
$op1
}
"
;
return
$this
;
}
private
function
escape
(
$data
)
private
function
escape
(
$data
)
{
{
if
(
$this
->
driver
instanceof
\X_DB_MySQLi
)
return
$this
->
driver
->
esc
(
$data
);
if
(
$this
->
driver
instanceof
\X_DB_MySQLi
)
return
$this
->
driver
->
esc
(
$data
);
...
@@ -253,11 +267,11 @@ class TableItem
...
@@ -253,11 +267,11 @@ class TableItem
public
function
exec
(
$op1
=
false
,
$op2
=
false
,
$op3
=
false
)
public
function
exec
(
$op1
=
false
,
$op2
=
false
,
$op3
=
false
)
{
{
if
(
$this
->
sql_type
==
"update"
&&
$this
->
driver
instanceof
\X_DB_MySQLi
)
if
(
$this
->
sql_type
==
"update"
&&
$this
->
driver
instanceof
\X_DB_MySQLi
)
return
$this
->
driver
->
rq
(
$this
->
sql
.
$this
->
sql_where
);
return
$this
->
driver
->
rq
(
$this
->
sql
.
$this
->
sql_where
);
if
(
$this
->
sql_type
==
"insert"
&&
$this
->
driver
instanceof
\X_DB_MySQLi
)
if
(
$this
->
sql_type
==
"insert"
&&
$this
->
driver
instanceof
\X_DB_MySQLi
)
return
$this
->
driver
->
insert
(
$this
->
sql
);
return
$this
->
driver
->
insert
(
$this
->
sql
);
if
(
$this
->
sql_type
==
"select"
&&
$this
->
driver
instanceof
\X_DB_MySQLi
)
if
(
$this
->
sql_type
==
"select"
&&
$this
->
driver
instanceof
\X_DB_MySQLi
)
return
$this
->
driver
->
get
(
$this
->
sql
.
$this
->
sql_where
,
$op1
,
$op2
,
$op3
);
return
$this
->
driver
->
get
(
$this
->
sql
.
$this
->
sql_where
.
$this
->
sql_order
.
$this
->
sql_limit
,
$op1
,
$op2
,
$op3
);
else
throw
new
\Exception
(
"Internal error"
,
0
);
else
throw
new
\Exception
(
"Internal error"
,
0
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment