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
4f02f9df
Commit
4f02f9df
authored
Aug 11, 2010
by
Jeffrey Way
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added additional abstraction and error handling
parent
2191bf3b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
8 deletions
+16
-8
MysqlDb.php
MysqlDb.php
+16
-8
No files found.
MysqlDb.php
View file @
4f02f9df
...
...
@@ -19,13 +19,12 @@ class MysqlDB {
* @param int $numRows The number of rows total to return.
* @return array Contains the returned rows from the query.
*/
public
function
query
(
$query
,
$numRows
=
NULL
)
public
function
query
(
$query
)
{
$this
->
_query
=
filter_var
(
$query
,
FILTER_SANITIZE_STRING
);
$stmt
=
$this
->
_mysql
->
prepare
(
$this
->
_query
);
$stmt
=
$this
->
_prepareQuery
(
);
$stmt
->
execute
();
$results
=
$this
->
_dynamicBindResults
(
$stmt
);
return
$results
;
}
...
...
@@ -152,13 +151,13 @@ class MysqlDB {
* @return object Returns the $stmt object.
*/
protected
function
_buildQuery
(
$numRows
=
NULL
,
$tableData
=
false
)
{
$hasTableData
=
null
;
if
(
gettype
(
$tableData
)
===
'array'
)
{
$hasTableData
=
true
;
}
// Did the user call the "where" method?
if
(
!
empty
(
$this
->
_where
)
)
{
if
(
!
empty
(
$this
->
_where
)
)
{
$keys
=
array_keys
(
$this
->
_where
);
$where_prop
=
$keys
[
0
];
$where_value
=
$this
->
_where
[
$where_prop
];
...
...
@@ -220,7 +219,7 @@ class MysqlDB {
}
// Prepare query
$stmt
=
$this
->
_mysql
->
prepare
(
$this
->
_query
)
or
die
(
'Problem preparing query.'
);
$stmt
=
$this
->
_prepareQuery
(
);
// Bind parameters
if
(
$hasTableData
)
{
...
...
@@ -233,7 +232,7 @@ class MysqlDB {
}
else
{
$stmt
->
bind_param
(
$this
->
_paramTypeList
,
$where_value
);
if
(
$this
->
_where
)
$stmt
->
bind_param
(
$this
->
_paramTypeList
,
$where_value
);
}
return
$stmt
;
...
...
@@ -270,4 +269,13 @@ class MysqlDB {
return
$results
;
}
protected
function
_prepareQuery
()
{
if
(
!
$stmt
=
$this
->
_mysql
->
prepare
(
$this
->
_query
)
)
{
trigger_error
(
"Connection issue"
,
E_USER_ERROR
);
}
return
$stmt
;
}
}
\ No newline at end of file
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