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
d531f032
Commit
d531f032
authored
Sep 15, 2016
by
Alex Ne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Багфикс
parent
537da486
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
119 additions
and
2 deletions
+119
-2
PDO.php
Database/Driver/PDO.php
+9
-1
PDOStatement.php
Database/Driver/PDOStatement.php
+108
-0
PDOWhereConstructor.php
Database/Driver/PDOWhereConstructor.php
+2
-1
No files found.
Database/Driver/PDO.php
View file @
d531f032
...
...
@@ -73,6 +73,7 @@ class PDO {
$this
->
Credetional
->
get_username
(),
$this
->
Credetional
->
get_password
());
$this
->
PDO
->
setAttribute
(
\PDO
::
ATTR_ERRMODE
,
\PDO
::
ERRMODE_EXCEPTION
);
//$this->PDO->setAttribute(\PDO::ATTR_STATEMENT_CLASS, ['X\Database\Driver\PDOStatement', [$this->PDO]]);
$this
->
set_charset
();
}
catch
(
\PDOException
$e
)
{
throw
new
PDO_ConnectionError
(
"Connection to database error"
,
1
,
[
...
...
@@ -189,6 +190,7 @@ class PDO {
* @param $SQL
*/
public
function
prepare
(
$SQL
)
{
return
new
PDOStatement
(
$this
->
PDO
,
$SQL
);
return
$this
->
PDO
->
prepare
(
$SQL
);
}
...
...
@@ -239,7 +241,7 @@ class PDO {
*/
public
function
simple
(
$table
,
$where
=
[],
$order
=
null
,
$limit
=
null
,
$columns
=
"*"
)
{
$statement
=
$this
->
select_statement
(
$table
,
$where
,
$order
,
1
,
$columns
);
if
(
$statement
->
column
Count
()
>
0
)
{
if
(
$statement
->
row
Count
()
>
0
)
{
return
$statement
->
fetchAll
(
\PDO
::
FETCH_ASSOC
)[
0
];
}
else
{
return
false
;
...
...
@@ -299,6 +301,12 @@ class PDO {
$columns
=
"*"
;
}
}
public
function
__sleep
()
{
return
[
'Credetional'
];
}
public
function
__wakeup
()
{}
}
?>
\ No newline at end of file
Database/Driver/PDOStatement.php
0 → 100644
View file @
d531f032
<?php
namespace
X\Database\Driver
;
use
\X\ETrace\System
as
ESys
;
class
PDOStatement
{
/**
* @var mixed
*/
protected
$db
;
/**
* @var mixed
*/
protected
$prepare
;
/**
* @param $db
*/
public
function
__construct
(
$db
,
$sql
)
{
$this
->
db
=
$db
;
$this
->
prepare
=
$this
->
db
->
prepare
(
$sql
);
}
/**
* @param $parameter
* @param $value
* @param $data_type
*/
public
function
bindValue
(
$parameter
,
$value
,
$data_type
=
\PDO
::
PARAM_STR
)
{
return
$this
->
prepare
->
bindValue
(
$parameter
,
$value
,
$data_type
);
}
/**
* @param $input_parameters
*/
public
function
execute
(
$input_parameters
=
null
)
{
if
(
$input_parameters
==
null
)
{
return
$this
->
prepare
->
execute
();
}
else
{
return
$this
->
prepare
->
execute
(
$input_parameters
);
}
}
/**
* @param $fetch_style
* @param null $cursor_orientation
* @param \PDOFETCH_ORI_NEXT $cursor_offset
* @return mixed
*/
public
function
fetch
(
$fetch_style
=
null
,
$cursor_orientation
=
\PDO
::
FETCH_ORI_NEXT
,
$cursor_offset
=
0
)
{
if
(
$fetch_style
==
null
)
{
return
$this
->
prepare
->
fetch
();
}
else
{
return
$this
->
prepare
->
fetch
(
$fetch_style
,
$cursor_orientation
,
$cursor_offset
);
}
}
/**
* @param $fetch_style
* @param null $fetch_argument
* @param array $ctor_args
* @return mixed
*/
public
function
fetchAll
(
$fetch_style
=
null
,
$fetch_argument
=
null
,
$ctor_args
=
[])
{
if
(
$fetch_style
==
null
)
{
return
$this
->
prepare
->
fetchAll
();
}
else
if
(
$fetch_argument
==
null
)
{
return
$this
->
prepare
->
fetchAll
(
$fetch_style
);
}
else
{
return
$this
->
prepare
->
fetchAll
(
$fetch_style
,
$fetch_argument
,
$ctor_args
);
}
}
/**
* @return mixed
*/
public
function
rowCount
()
{
return
$this
->
prepare
->
rowCount
();
}
/**
* @return mixed
*/
public
function
columnCount
()
{
return
$this
->
prepare
->
columnCount
();
}
/**
* @param $attribute
* @param $value
* @return mixed
*/
public
function
setAttribute
(
$attribute
,
$value
)
{
return
$this
->
prepare
->
setAttribute
(
$attribute
,
$value
);
}
/**
* @param $mode
* @return mixed
*/
public
function
setFetchMode
(
$mode
)
{
return
$this
->
prepare
->
setFetchMode
(
$mode
);
}
public
function
__sleep
()
{
return
[];}
public
function
__wakeup
()
{}
}
?>
\ No newline at end of file
Database/Driver/PDOWhereConstructor.php
View file @
d531f032
...
...
@@ -38,6 +38,7 @@ class PDOWhereConstructor {
* @param $data
*/
public
function
__construct
(
$data
=
[])
{
$this
->
data_set
=
[];
$this
->
Parse
(
$data
);
}
...
...
@@ -60,7 +61,7 @@ class PDOWhereConstructor {
*/
public
function
Parse
(
$data
=
[])
{
if
(
is_array
(
$data
))
{
if
(
count
(
$data
>
0
)
)
{
if
(
count
(
$data
)
>
0
)
{
$this
->
SQL
=
"WHERE "
;
$this
->
SQL
.=
$this
->
build_where_string
(
$data
);
}
else
{
...
...
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