Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
PHP-MySQLi-Database-Class
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
PHP-MySQLi-Database-Class
Commits
f17feb4b
Commit
f17feb4b
authored
Mar 26, 2014
by
Alexander Butenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store last statement error as mysqli->error is not including them.
parent
5dbd1c90
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
MysqliDb.php
MysqliDb.php
+13
-2
No files found.
MysqliDb.php
View file @
f17feb4b
...
@@ -80,7 +80,12 @@ class MysqliDb
...
@@ -80,7 +80,12 @@ class MysqliDb
* @var string
* @var string
*/
*/
public
$count
=
0
;
public
$count
=
0
;
/**
* Variable which holds last statement error
*
* @var string
*/
protected
$_stmtError
;
/**
/**
* @param string $host
* @param string $host
* @param string $username
* @param string $username
...
@@ -158,6 +163,7 @@ class MysqliDb
...
@@ -158,6 +163,7 @@ class MysqliDb
}
}
$stmt
->
execute
();
$stmt
->
execute
();
$this
->
_stmtError
=
$stmt
->
error
;
$this
->
reset
();
$this
->
reset
();
return
$this
->
_dynamicBindResults
(
$stmt
);
return
$this
->
_dynamicBindResults
(
$stmt
);
...
@@ -175,6 +181,7 @@ class MysqliDb
...
@@ -175,6 +181,7 @@ class MysqliDb
$this
->
_query
=
filter_var
(
$query
,
FILTER_SANITIZE_STRING
);
$this
->
_query
=
filter_var
(
$query
,
FILTER_SANITIZE_STRING
);
$stmt
=
$this
->
_buildQuery
(
$numRows
);
$stmt
=
$this
->
_buildQuery
(
$numRows
);
$stmt
->
execute
();
$stmt
->
execute
();
$this
->
_stmtError
=
$stmt
->
error
;
$this
->
reset
();
$this
->
reset
();
return
$this
->
_dynamicBindResults
(
$stmt
);
return
$this
->
_dynamicBindResults
(
$stmt
);
...
@@ -197,6 +204,7 @@ class MysqliDb
...
@@ -197,6 +204,7 @@ class MysqliDb
$this
->
_query
=
"SELECT
$column
FROM
$tableName
"
;
$this
->
_query
=
"SELECT
$column
FROM
$tableName
"
;
$stmt
=
$this
->
_buildQuery
(
$numRows
);
$stmt
=
$this
->
_buildQuery
(
$numRows
);
$stmt
->
execute
();
$stmt
->
execute
();
$this
->
_stmtError
=
$stmt
->
error
;
$this
->
reset
();
$this
->
reset
();
return
$this
->
_dynamicBindResults
(
$stmt
);
return
$this
->
_dynamicBindResults
(
$stmt
);
...
@@ -227,6 +235,7 @@ class MysqliDb
...
@@ -227,6 +235,7 @@ class MysqliDb
$this
->
_query
=
"INSERT into
$tableName
"
;
$this
->
_query
=
"INSERT into
$tableName
"
;
$stmt
=
$this
->
_buildQuery
(
null
,
$insertData
);
$stmt
=
$this
->
_buildQuery
(
null
,
$insertData
);
$stmt
->
execute
();
$stmt
->
execute
();
$this
->
_stmtError
=
$stmt
->
error
;
$this
->
reset
();
$this
->
reset
();
return
(
$stmt
->
affected_rows
>
0
?
$stmt
->
insert_id
:
false
);
return
(
$stmt
->
affected_rows
>
0
?
$stmt
->
insert_id
:
false
);
...
@@ -246,6 +255,7 @@ class MysqliDb
...
@@ -246,6 +255,7 @@ class MysqliDb
$stmt
=
$this
->
_buildQuery
(
null
,
$tableData
);
$stmt
=
$this
->
_buildQuery
(
null
,
$tableData
);
$stmt
->
execute
();
$stmt
->
execute
();
$this
->
_stmtError
=
$stmt
->
error
;
$this
->
reset
();
$this
->
reset
();
return
(
$stmt
->
affected_rows
>
0
);
return
(
$stmt
->
affected_rows
>
0
);
...
@@ -265,6 +275,7 @@ class MysqliDb
...
@@ -265,6 +275,7 @@ class MysqliDb
$stmt
=
$this
->
_buildQuery
(
$numRows
);
$stmt
=
$this
->
_buildQuery
(
$numRows
);
$stmt
->
execute
();
$stmt
->
execute
();
$this
->
_stmtError
=
$stmt
->
error
;
$this
->
reset
();
$this
->
reset
();
return
(
$stmt
->
affected_rows
>
0
);
return
(
$stmt
->
affected_rows
>
0
);
...
@@ -720,7 +731,7 @@ class MysqliDb
...
@@ -720,7 +731,7 @@ class MysqliDb
* @return string
* @return string
*/
*/
public
function
getLastError
()
{
public
function
getLastError
()
{
return
$this
->
_mysqli
->
error
;
return
$this
->
_
stmtError
.
" "
.
$this
->
_
mysqli
->
error
;
}
}
/* Helper functions */
/* Helper functions */
...
...
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