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
44263146
Commit
44263146
authored
Apr 14, 2014
by
Alexander Butenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Streamline variable bindings
parent
b1d87156
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
50 deletions
+16
-50
MysqliDb.php
MysqliDb.php
+16
-50
No files found.
MysqliDb.php
View file @
44263146
...
...
@@ -48,12 +48,6 @@ class MysqliDb
* @var array
*/
protected
$_where
=
array
();
/**
* Dynamic type list for where condition values
*
* @var array
*/
protected
$_whereTypeList
;
/**
* Dynamic type list for order by condition value
*/
...
...
@@ -62,12 +56,6 @@ class MysqliDb
* Dynamic type list for group by condition value
*/
protected
$_groupBy
=
array
();
/**
* Dynamic type list for table data values
*
* @var array
*/
protected
$_paramTypeList
;
/**
* Dynamic array that holds a combination of where condition/table data value types and parameter referances
*
...
...
@@ -133,8 +121,6 @@ class MysqliDb
$this
->
_groupBy
=
array
();
$this
->
_bindParams
=
array
(
''
);
// Create the empty 0 index
$this
->
_query
=
null
;
$this
->
_whereTypeList
=
null
;
$this
->
_paramTypeList
=
null
;
$this
->
count
=
0
;
}
...
...
@@ -472,7 +458,8 @@ class MysqliDb
$this
->
_query
.=
$column
.
" = "
;
if
(
!
is_array
(
$value
))
{
$this
->
_paramTypeList
.=
$this
->
_determineType
(
$value
);
$this
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$value
);
array_push
(
$this
->
_bindParams
,
$value
);
$this
->
_query
.=
'?, '
;
}
else
{
$key
=
key
(
$value
);
...
...
@@ -484,8 +471,10 @@ class MysqliDb
case
'[F]'
:
$this
->
_query
.=
$val
[
0
]
.
", "
;
if
(
!
empty
(
$val
[
1
]))
{
foreach
(
$val
[
1
]
as
$v
)
$this
->
_paramTypeList
.=
$this
->
_determineType
(
$v
);
foreach
(
$val
[
1
]
as
$v
)
{
$this
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$v
);
array_push
(
$this
->
_bindParams
,
$v
);
}
}
break
;
default
:
...
...
@@ -519,24 +508,29 @@ class MysqliDb
$comparison
=
' IN ('
;
foreach
(
$val
as
$v
){
$comparison
.=
' ?,'
;
$this
->
_whereTypeList
.=
$this
->
_determineType
(
$v
);
$this
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$v
);
array_push
(
$this
->
_bindParams
,
$v
);
}
$comparison
=
rtrim
(
$comparison
,
','
)
.
' ) '
;
break
;
case
'between'
:
$comparison
=
' BETWEEN ? AND ? '
;
$this
->
_whereTypeList
.=
$this
->
_determineType
(
$val
[
0
]
);
$this
->
_whereTypeList
.=
$this
->
_determineType
(
$val
[
1
]
);
$this
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$val
[
0
]
);
$this
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$val
[
1
]
);
array_push
(
$this
->
_bindParams
,
$val
[
0
]);
array_push
(
$this
->
_bindParams
,
$val
[
1
]);
break
;
default
:
// We are using a comparison operator with only one parameter after it
$comparison
=
' '
.
$key
.
' ? '
;
// Determines what data type the where column is, for binding purposes.
$this
->
_whereTypeList
.=
$this
->
_determineType
(
$val
);
$this
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$val
);
array_push
(
$this
->
_bindParams
,
$val
);
}
}
else
{
// Determines what data type the where column is, for binding purposes.
$this
->
_whereTypeList
.=
$this
->
_determineType
(
$value
);
$this
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$value
);
array_push
(
$this
->
_bindParams
,
$value
);
}
// Prepares the reset of the SQL query.
$this
->
_query
.=
(
$andOr
.
$column
.
$comparison
);
...
...
@@ -574,34 +568,6 @@ class MysqliDb
// Prepare query
$stmt
=
$this
->
_prepareQuery
();
// Prepare table data bind parameters
if
(
$hasTableData
)
{
$this
->
_bindParams
[
0
]
=
$this
->
_paramTypeList
;
foreach
(
$tableData
as
$val
)
{
if
(
!
is_array
(
$val
))
{
array_push
(
$this
->
_bindParams
,
$val
);
}
else
if
(
!
empty
(
$val
[
'[F]'
][
1
])
&&
is_array
(
$val
[
'[F]'
][
1
]))
{
// collect func() arguments
foreach
(
$val
[
'[F]'
][
1
]
as
$val
)
array_push
(
$this
->
_bindParams
,
$val
);
}
}
}
// Prepare where condition bind parameters
if
(
$hasConditional
)
{
if
(
$this
->
_where
)
{
$this
->
_bindParams
[
0
]
.=
$this
->
_whereTypeList
;
foreach
(
$this
->
_where
as
$val
)
{
$val
=
$val
[
1
];
if
(
!
is_array
(
$val
))
{
array_push
(
$this
->
_bindParams
,
$val
);
}
else
{
foreach
(
$val
as
$v
)
array_push
(
$this
->
_bindParams
,
$v
);
}
}
}
}
// Bind parameters to statment
if
(
$hasTableData
||
$hasConditional
)
{
call_user_func_array
(
array
(
$stmt
,
'bind_param'
),
$this
->
refValues
(
$this
->
_bindParams
));
...
...
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