Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
4161fd24
Commit
4161fd24
authored
Aug 23, 2013
by
Jonny007-MKD
Committed by
Jörn Friedrich Dreyer
Jul 01, 2014
Browse files
Update adapter.php
Modified insertIfNotExist() to support NULL values
parent
19a6dc54
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/private/db/adapter.php
View file @
4161fd24
...
...
@@ -51,13 +51,18 @@ class Adapter {
.
str_repeat
(
'?,'
,
count
(
$input
)
-
1
)
.
'? '
// Is there a prettier alternative?
.
'FROM `'
.
$table
.
'` WHERE '
;
$inserts
=
array_values
(
$input
);
foreach
(
$input
as
$key
=>
$value
)
{
$query
.
=
'`'
.
$key
.
'` = ? AND '
;
$query
.
=
'`'
.
$key
.
'`'
;
if
(
is_null
(
$value
))
{
$query
.
=
' IS NULL AND '
;
}
else
{
$inserts
[]
=
$value
;
$query
.
=
' = ? AND '
;
}
}
$query
=
substr
(
$query
,
0
,
strlen
(
$query
)
-
5
);
$query
.
=
' HAVING COUNT(*) = 0'
;
$inserts
=
array_values
(
$input
);
$inserts
=
array_merge
(
$inserts
,
$inserts
);
try
{
return
$this
->
conn
->
executeUpdate
(
$query
,
$inserts
);
...
...
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