Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
432b6ba4
Commit
432b6ba4
authored
Feb 11, 2016
by
Carsten Rose
Browse files
Database.php: bind_param rewritten to use class BindParam.
parent
049c9b3e
Changes
1
Hide whitespace changes
Inline
Side-by-side
extension/qfq/qfq/Database.php
View file @
432b6ba4
...
...
@@ -308,6 +308,7 @@ class Database {
throw
new
DbException
(
'[ mysqli: '
.
$this
->
mysqli
->
errno
.
' ] '
.
$this
->
mysqli
->
error
,
ERROR_DB_PREPARE
);
}
if
(
count
(
$parameterArray
)
>
0
)
{
if
(
false
===
$this
->
fakeCallUserFunc
(
$parameterArray
))
{
throw
new
DbException
(
'[ mysqli: '
.
$this
->
mysqli_stmt
->
errno
.
' ] '
.
$this
->
mysqli_stmt
->
error
,
ERROR_DB_BIND
);
...
...
@@ -391,44 +392,52 @@ class Database {
*/
private
function
fakeCallUserFunc
(
$arr
)
{
$type
=
''
;
// $type = '';
//
// foreach ($arr as $value) {
// if (is_int($value)) {
// $type .= 'i';
// } elseif (is_double($value)) {
// $type .= 'd';
// } else {
// $type .= 's';
// }
// }
foreach
(
$arr
as
$value
)
{
if
(
is_int
(
$value
))
{
$type
.
=
'i'
;
}
elseif
(
is_double
(
$value
))
{
$type
.
=
'd'
;
}
else
{
$type
.
=
's'
;
}
}
switch
(
count
(
$arr
))
{
case
0
:
break
;
case
1
:
$this
->
mysqli_stmt
->
bind_param
(
$type
,
$arr
[
0
]);
break
;
case
2
:
$this
->
mysqli_stmt
->
bind_param
(
$type
,
$arr
[
0
],
$arr
[
1
]);
break
;
case
3
:
$this
->
mysqli_stmt
->
bind_param
(
$type
,
$arr
[
0
],
$arr
[
1
],
$arr
[
2
]);
break
;
case
4
:
$this
->
mysqli_stmt
->
bind_param
(
$type
,
$arr
[
0
],
$arr
[
1
],
$arr
[
2
],
$arr
[
3
]);
break
;
case
5
:
$this
->
mysqli_stmt
->
bind_param
(
$type
,
$arr
[
0
],
$arr
[
1
],
$arr
[
2
],
$arr
[
3
],
$arr
[
4
]);
break
;
case
6
:
$this
->
mysqli_stmt
->
bind_param
(
$type
,
$arr
[
0
],
$arr
[
1
],
$arr
[
2
],
$arr
[
3
],
$arr
[
4
],
$arr
[
5
]);
break
;
case
7
:
$this
->
mysqli_stmt
->
bind_param
(
$type
,
$arr
[
0
],
$arr
[
1
],
$arr
[
2
],
$arr
[
3
],
$arr
[
4
],
$arr
[
5
],
$arr
[
6
]);
break
;
default
:
throw
new
DbException
(
'Oops, too many parameter in prepared statement.'
,
0
);
$bindParam
=
new
BindParam
();
for
(
$ii
=
0
;
$ii
<
count
(
$arr
);
$ii
++
)
{
$bindParam
->
add
(
$arr
[
$ii
]);
}
call_user_func_array
([
$this
->
mysqli_stmt
,
'bind_param'
],
$bindParam
->
get
());
// switch (count($arr)) {
// case 0:
// break;
// case 1:
// $this->mysqli_stmt->bind_param($type, $arr[0]);
// break;
// case 2:
// $this->mysqli_stmt->bind_param($type, $arr[0], $arr[1]);
// break;
// case 3:
// $this->mysqli_stmt->bind_param($type, $arr[0], $arr[1], $arr[2]);
// break;
// case 4:
// $this->mysqli_stmt->bind_param($type, $arr[0], $arr[1], $arr[2], $arr[3]);
// break;
// case 5:
// $this->mysqli_stmt->bind_param($type, $arr[0], $arr[1], $arr[2], $arr[3], $arr[4]);
// break;
// case 6:
// $this->mysqli_stmt->bind_param($type, $arr[0], $arr[1], $arr[2], $arr[3], $arr[4], $arr[5]);
// break;
// case 7:
// $this->mysqli_stmt->bind_param($type, $arr[0], $arr[1], $arr[2], $arr[3], $arr[4], $arr[5], $arr[6]);
// break;
// default:
// throw new DbException('Oops, too many parameter in prepared statement.', 0);
// }
}
/**
...
...
Write
Preview
Supports
Markdown
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