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
d08d9af8
Commit
d08d9af8
authored
Aug 27, 2016
by
Alex Ne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Добавлена функция first
parent
95b8140a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
+31
-0
MySQLi.php
DB/MySQLi.php
+13
-0
TableItem.php
DB/TableItem.php
+18
-0
No files found.
DB/MySQLi.php
View file @
d08d9af8
...
...
@@ -328,6 +328,19 @@ class X_DB_MySQLi {
}
}
/**
* @param $SQL
* @return mixed
*/
public
function
first
(
$SQL
)
{
$data
=
$this
->
get
(
$SQL
);
if
(
is_array
(
$data
)
&&
count
(
$data
)
>
0
)
{
return
$data
[
0
];
}
else
{
return
false
;
}
}
/**
* @param $table
* @param $column
...
...
DB/TableItem.php
View file @
d08d9af8
...
...
@@ -89,6 +89,21 @@ class TableItem {
return
$this
;
}
public
function
first
()
{
$columns
=
func_get_args
();
if
(
count
(
$columns
)
==
1
&&
is_array
(
$columns
[
0
]))
{
$columns
=
"`"
.
implode
(
"`,`"
,
$columns
[
0
])
.
"`"
;
}
else
if
(
count
(
$columns
)
>
1
)
{
$columns
=
"`"
.
implode
(
"`,`"
,
$columns
)
.
"`"
;
}
else
{
$columns
=
"*"
;
}
$this
->
sql_type
=
"first"
;
$this
->
sql
=
"SELECT
{
$columns
}
FROM `
{
$this
->
table_name
}
`"
;
return
$this
;
}
public
function
select
()
{
$columns
=
func_get_args
();
if
(
count
(
$columns
)
==
1
&&
is_array
(
$columns
[
0
]))
{
...
...
@@ -333,6 +348,9 @@ class TableItem {
if
(
$this
->
sql_type
==
"select"
&&
$this
->
driver
instanceof
\X_DB_MySQLi
)
{
return
$this
->
driver
->
get
(
$this
->
sql
.
$this
->
sql_where
.
$this
->
sql_order
.
$this
->
sql_limit
,
$op1
,
$op2
,
$op3
);
}
if
(
$this
->
sql_type
==
"first"
&&
$this
->
driver
instanceof
\X_DB_MySQLi
)
{
return
$this
->
driver
->
first
(
$this
->
sql
.
$this
->
sql_where
.
$this
->
sql_order
.
$this
->
sql_limit
,
$op1
,
$op2
,
$op3
);
}
if
(
$this
->
sql_type
==
"delete"
&&
$this
->
driver
instanceof
\X_DB_MySQLi
)
{
return
$this
->
driver
->
rq
(
$this
->
sql
.
$this
->
sql_where
);
}
...
...
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