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
76cc087b
Commit
76cc087b
authored
Apr 30, 2014
by
Alexander Butenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add _bindParam internal helper function
parent
b0d971fc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
16 deletions
+19
-16
MysqliDb.php
MysqliDb.php
+19
-16
No files found.
MysqliDb.php
View file @
76cc087b
...
...
@@ -420,6 +420,17 @@ class MysqliDb
return
''
;
}
/**
* Helper function to add variables into bind parameters array
*
* @param string Variable value
*/
protected
function
_bindParam
(
$value
)
{
$this
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$value
);
array_push
(
$this
->
_bindParams
,
$value
);
}
/**
* Abstraction method that will compile the WHERE statement,
* any passed update data, and the desired rows.
...
...
@@ -458,8 +469,7 @@ class MysqliDb
$this
->
_query
.=
$column
.
" = "
;
if
(
!
is_array
(
$value
))
{
$this
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$value
);
array_push
(
$this
->
_bindParams
,
$value
);
$this
->
_bindParam
(
$value
);
$this
->
_query
.=
'?, '
;
}
else
{
$key
=
key
(
$value
);
...
...
@@ -471,10 +481,8 @@ class MysqliDb
case
'[F]'
:
$this
->
_query
.=
$val
[
0
]
.
", "
;
if
(
!
empty
(
$val
[
1
]))
{
foreach
(
$val
[
1
]
as
$v
)
{
$this
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$v
);
array_push
(
$this
->
_bindParams
,
$v
);
}
foreach
(
$val
[
1
]
as
$v
)
$this
->
_bindParam
(
$v
);
}
break
;
case
'[N]'
:
...
...
@@ -512,29 +520,24 @@ class MysqliDb
$comparison
=
' IN ('
;
foreach
(
$val
as
$v
){
$comparison
.=
' ?,'
;
$this
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$v
);
array_push
(
$this
->
_bindParams
,
$v
);
$this
->
_bindParam
(
$v
);
}
$comparison
=
rtrim
(
$comparison
,
','
)
.
' ) '
;
break
;
case
'between'
:
$comparison
=
' BETWEEN ? AND ? '
;
$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
]);
$this
->
_bindParam
(
$val
[
0
]);
$this
->
_bindParam
(
$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
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$val
);
array_push
(
$this
->
_bindParams
,
$val
);
$this
->
_bindParam
(
$val
);
}
}
else
{
// Determines what data type the where column is, for binding purposes.
$this
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$value
);
array_push
(
$this
->
_bindParams
,
$value
);
$this
->
_bindParam
(
$value
);
}
// Prepares the reset of the SQL query.
$this
->
_query
.=
(
$andOr
.
$column
.
$comparison
);
...
...
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