Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
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
Tomáš Trávníček
doctrine-dbal
Commits
f4437acb
Commit
f4437acb
authored
Jun 23, 2017
by
Jonathan Vollebregt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Connection: insert/update/delete variable naming cleanup
parent
cab04d0e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
32 deletions
+32
-32
Connection.php
lib/Doctrine/DBAL/Connection.php
+32
-32
No files found.
lib/Doctrine/DBAL/Connection.php
View file @
f4437acb
...
...
@@ -603,33 +603,33 @@ class Connection implements DriverConnection
}
/**
* Gathers c
riteria
for an update or delete call.
* Gathers c
onditions
for an update or delete call.
*
* @param array $identifiers Input array of columns to values
*
* @return string[][] a triplet with:
* - the first key being the column
name
s
* - the first key being the columns
* - the second key being the values
* - the third key being the c
riteria string
s
* - the third key being the c
ondition
s
*/
private
function
gatherC
riteria
(
array
$identifiers
)
private
function
gatherC
onditions
(
array
$identifiers
)
{
$columns
=
[];
$values
=
[];
$c
riteria
=
[];
$c
onditions
=
[];
foreach
(
$identifiers
as
$columnName
=>
$value
)
{
if
(
null
===
$value
)
{
$c
riteria
[]
=
$this
->
getDatabasePlatform
()
->
getIsNullExpression
(
$columnName
);
$c
onditions
[]
=
$this
->
getDatabasePlatform
()
->
getIsNullExpression
(
$columnName
);
continue
;
}
$columns
[]
=
$columnName
;
$values
[]
=
$value
;
$c
riteria
[]
=
$columnName
.
' = ?'
;
$c
onditions
[]
=
$columnName
.
' = ?'
;
}
return
[
$columns
,
$values
,
$c
riteria
];
return
[
$columns
,
$values
,
$c
onditions
];
}
/**
...
...
@@ -651,12 +651,12 @@ class Connection implements DriverConnection
throw
InvalidArgumentException
::
fromEmptyCriteria
();
}
list
(
$column
List
,
$paramValues
,
$criteria
)
=
$this
->
gatherCriteria
(
$identifier
);
list
(
$column
s
,
$values
,
$conditions
)
=
$this
->
gatherConditions
(
$identifier
);
return
$this
->
executeUpdate
(
'DELETE FROM '
.
$tableExpression
.
' WHERE '
.
implode
(
' AND '
,
$c
riteria
),
$
paramV
alues
,
is_string
(
key
(
$types
))
?
$this
->
extractTypeValues
(
$column
List
,
$types
)
:
$types
'DELETE FROM '
.
$tableExpression
.
' WHERE '
.
implode
(
' AND '
,
$c
onditions
),
$
v
alues
,
is_string
(
key
(
$types
))
?
$this
->
extractTypeValues
(
$column
s
,
$types
)
:
$types
);
}
...
...
@@ -714,28 +714,28 @@ class Connection implements DriverConnection
*/
public
function
update
(
$tableExpression
,
array
$data
,
array
$identifier
,
array
$types
=
array
())
{
$columnList
=
array
();
$setColumns
=
array
();
$setValues
=
array
();
$set
=
array
();
$paramValues
=
array
();
foreach
(
$data
as
$columnName
=>
$value
)
{
$columnList
[]
=
$columnName
;
$setColumns
[]
=
$columnName
;
$setValues
[]
=
$value
;
$set
[]
=
$columnName
.
' = ?'
;
$paramValues
[]
=
$value
;
}
list
(
$
whereColumns
,
$whereValues
,
$criteria
)
=
$this
->
gatherCriteria
(
$identifier
);
$column
List
=
array_merge
(
$columnList
,
$where
Columns
);
$
paramValues
=
array_merge
(
$paramValues
,
$where
Values
);
list
(
$
conditionColumns
,
$conditionValues
,
$conditions
)
=
$this
->
gatherConditions
(
$identifier
);
$column
s
=
array_merge
(
$setColumns
,
$condition
Columns
);
$
values
=
array_merge
(
$setValues
,
$condition
Values
);
if
(
is_string
(
key
(
$types
)))
{
$types
=
$this
->
extractTypeValues
(
$column
List
,
$types
);
$types
=
$this
->
extractTypeValues
(
$column
s
,
$types
);
}
$sql
=
'UPDATE '
.
$tableExpression
.
' SET '
.
implode
(
', '
,
$set
)
.
' WHERE '
.
implode
(
' AND '
,
$c
riteria
);
.
' WHERE '
.
implode
(
' AND '
,
$c
onditions
);
return
$this
->
executeUpdate
(
$sql
,
$
paramV
alues
,
$types
);
return
$this
->
executeUpdate
(
$sql
,
$
v
alues
,
$types
);
}
/**
...
...
@@ -755,21 +755,21 @@ class Connection implements DriverConnection
return
$this
->
executeUpdate
(
'INSERT INTO '
.
$tableExpression
.
' ()'
.
' VALUES ()'
);
}
$column
List
=
array
();
$
paramPlaceholder
s
=
array
();
$
paramValues
=
array
();
$column
s
=
array
();
$
value
s
=
array
();
$
set
=
array
();
foreach
(
$data
as
$columnName
=>
$value
)
{
$column
List
[]
=
$columnName
;
$
paramPlaceholders
[]
=
'?'
;
$
paramValues
[]
=
$value
;
$column
s
[]
=
$columnName
;
$
values
[]
=
$value
;
$
set
[]
=
'?'
;
}
return
$this
->
executeUpdate
(
'INSERT INTO '
.
$tableExpression
.
' ('
.
implode
(
', '
,
$column
List
)
.
')'
.
' VALUES ('
.
implode
(
', '
,
$
paramPlaceholders
)
.
')'
,
$
paramV
alues
,
is_string
(
key
(
$types
))
?
$this
->
extractTypeValues
(
$column
List
,
$types
)
:
$types
'INSERT INTO '
.
$tableExpression
.
' ('
.
implode
(
', '
,
$column
s
)
.
')'
.
' VALUES ('
.
implode
(
', '
,
$
set
)
.
')'
,
$
v
alues
,
is_string
(
key
(
$types
))
?
$this
->
extractTypeValues
(
$column
s
,
$types
)
:
$types
);
}
...
...
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