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
Hide 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
...
@@ -420,6 +420,17 @@ class MysqliDb
return
''
;
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,
* Abstraction method that will compile the WHERE statement,
* any passed update data, and the desired rows.
* any passed update data, and the desired rows.
...
@@ -458,8 +469,7 @@ class MysqliDb
...
@@ -458,8 +469,7 @@ class MysqliDb
$this
->
_query
.=
$column
.
" = "
;
$this
->
_query
.=
$column
.
" = "
;
if
(
!
is_array
(
$value
))
{
if
(
!
is_array
(
$value
))
{
$this
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$value
);
$this
->
_bindParam
(
$value
);
array_push
(
$this
->
_bindParams
,
$value
);
$this
->
_query
.=
'?, '
;
$this
->
_query
.=
'?, '
;
}
else
{
}
else
{
$key
=
key
(
$value
);
$key
=
key
(
$value
);
...
@@ -471,10 +481,8 @@ class MysqliDb
...
@@ -471,10 +481,8 @@ class MysqliDb
case
'[F]'
:
case
'[F]'
:
$this
->
_query
.=
$val
[
0
]
.
", "
;
$this
->
_query
.=
$val
[
0
]
.
", "
;
if
(
!
empty
(
$val
[
1
]))
{
if
(
!
empty
(
$val
[
1
]))
{
foreach
(
$val
[
1
]
as
$v
)
{
foreach
(
$val
[
1
]
as
$v
)
$this
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$v
);
$this
->
_bindParam
(
$v
);
array_push
(
$this
->
_bindParams
,
$v
);
}
}
}
break
;
break
;
case
'[N]'
:
case
'[N]'
:
...
@@ -512,29 +520,24 @@ class MysqliDb
...
@@ -512,29 +520,24 @@ class MysqliDb
$comparison
=
' IN ('
;
$comparison
=
' IN ('
;
foreach
(
$val
as
$v
){
foreach
(
$val
as
$v
){
$comparison
.=
' ?,'
;
$comparison
.=
' ?,'
;
$this
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$v
);
$this
->
_bindParam
(
$v
);
array_push
(
$this
->
_bindParams
,
$v
);
}
}
$comparison
=
rtrim
(
$comparison
,
','
)
.
' ) '
;
$comparison
=
rtrim
(
$comparison
,
','
)
.
' ) '
;
break
;
break
;
case
'between'
:
case
'between'
:
$comparison
=
' BETWEEN ? AND ? '
;
$comparison
=
' BETWEEN ? AND ? '
;
$this
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$val
[
0
]
);
$this
->
_bindParam
(
$val
[
0
]);
$this
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$val
[
1
]
);
$this
->
_bindParam
(
$val
[
1
]);
array_push
(
$this
->
_bindParams
,
$val
[
0
]);
array_push
(
$this
->
_bindParams
,
$val
[
1
]);
break
;
break
;
default
:
default
:
// We are using a comparison operator with only one parameter after it
// We are using a comparison operator with only one parameter after it
$comparison
=
' '
.
$key
.
' ? '
;
$comparison
=
' '
.
$key
.
' ? '
;
// Determines what data type the where column is, for binding purposes.
// Determines what data type the where column is, for binding purposes.
$this
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$val
);
$this
->
_bindParam
(
$val
);
array_push
(
$this
->
_bindParams
,
$val
);
}
}
}
else
{
}
else
{
// Determines what data type the where column is, for binding purposes.
// Determines what data type the where column is, for binding purposes.
$this
->
_bindParams
[
0
]
.=
$this
->
_determineType
(
$value
);
$this
->
_bindParam
(
$value
);
array_push
(
$this
->
_bindParams
,
$value
);
}
}
// Prepares the reset of the SQL query.
// Prepares the reset of the SQL query.
$this
->
_query
.=
(
$andOr
.
$column
.
$comparison
);
$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