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
bca6c934
Commit
bca6c934
authored
Oct 23, 2010
by
Josh Campbell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize and clean up code
parent
479f2c64
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
28 deletions
+23
-28
MysqliDb.php
MysqliDb.php
+23
-28
No files found.
MysqliDb.php
View file @
bca6c934
...
...
@@ -61,15 +61,17 @@ class MysqliDB {
$this
->
_query
=
filter_var
(
$query
,
FILTER_SANITIZE_STRING
);
$stmt
=
$this
->
_prepareQuery
();
if
(
gettype
(
$bindParams
)
===
'array'
)
{
if
(
gettype
(
$bindParams
)
===
'array'
)
{
$params
=
array
(
''
);
foreach
(
$bindParams
as
$prop
=>
$val
)
{
foreach
(
$bindParams
as
$prop
=>
$val
)
{
$params
[
0
]
.=
$this
->
_determineType
(
$val
);
array_push
(
$params
,
&
$bindParams
[
$prop
]);
}
echo
'<pre>'
;
print_r
(
$params
);
echo
'</pre>'
;
call_user_func_array
(
array
(
$stmt
,
'bind_param'
),
$params
);
}
...
...
@@ -226,19 +228,14 @@ class MysqliDB {
$hasTableData
=
true
;
// Did the user call the "where" method?
if
(
!
empty
(
$this
->
_where
))
{
if
(
!
empty
(
$this
->
_where
))
{
// if update data was passed, filter through and create the SQL query, accordingly.
if
(
$hasTableData
)
{
if
(
$hasTableData
)
{
$i
=
1
;
$pos
=
strpos
(
$this
->
_query
,
'UPDATE'
);
if
(
$pos
!==
false
)
{
foreach
(
$tableData
as
$prop
=>
$value
)
{
if
(
$pos
!==
false
)
{
foreach
(
$tableData
as
$prop
=>
$value
)
{
// determines what data type the item is, for binding purposes.
$this
->
_paramTypeList
.=
$this
->
_determineType
(
$value
);
...
...
@@ -255,8 +252,7 @@ class MysqliDB {
//Prepair the where portion of the query
$this
->
_query
.=
' WHERE '
;
$i
=
1
;
foreach
(
$this
->
_where
as
$column
=>
$value
)
{
foreach
(
$this
->
_where
as
$column
=>
$value
)
{
// Determines what data type the where column is, for binding purposes.
$this
->
_whereTypeList
.=
$this
->
_determineType
(
$value
);
...
...
@@ -306,23 +302,22 @@ class MysqliDB {
// Bind parameters
if
(
$hasTableData
)
{
$args
=
array
();
$args
[]
=
$this
->
_paramTypeList
;
array_push
(
$args
,
$this
->
_paramTypeList
)
;
foreach
(
$tableData
as
$prop
=>
$val
)
{
$args
[]
=
&
$tableData
[
$prop
]
;
array_push
(
$args
,
&
$tableData
[
$prop
])
;
}
call_user_func_array
(
array
(
$stmt
,
'bind_param'
),
$args
);
}
else
{
if
(
$this
->
_where
)
{
$wheres
=
array
();
$wheres
[]
=
$this
->
_whereTypeList
;
foreach
(
$this
->
_where
as
$prop
=>
$val
)
{
$wheres
[]
=
&
$this
->
_where
[
$prop
];
}
if
(
$this
->
_where
)
{
$wheres
=
array
();
array_push
(
$wheres
,
$this
->
_whereTypeList
);
foreach
(
$this
->
_where
as
$prop
=>
$val
)
{
array_push
(
$wheres
,
&
$this
->
_where
[
$prop
]);
}
call_user_func_array
(
array
(
$stmt
,
'bind_param'
),
$wheres
);
}
call_user_func_array
(
array
(
$stmt
,
'bind_param'
),
$wheres
);
}
}
return
$stmt
;
...
...
@@ -343,7 +338,7 @@ class MysqliDB {
$meta
=
$stmt
->
result_metadata
();
while
(
$field
=
$meta
->
fetch_field
())
{
$parameters
[]
=
&
$row
[
$field
->
name
]
;
array_push
(
$parameters
,
&
$row
[
$field
->
name
])
;
}
call_user_func_array
(
array
(
$stmt
,
'bind_result'
),
$parameters
);
...
...
@@ -353,7 +348,7 @@ class MysqliDB {
foreach
(
$row
as
$key
=>
$val
)
{
$x
[
$key
]
=
$val
;
}
$results
[]
=
$x
;
array_push
(
$results
,
$x
)
;
}
return
$results
;
}
...
...
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