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
c61361d8
Commit
c61361d8
authored
Mar 06, 2014
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make API for Connection#insert, update and delete more explicit about expressions not names.
parent
149f1800
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
+16
-10
Connection.php
lib/Doctrine/DBAL/Connection.php
+16
-10
No files found.
lib/Doctrine/DBAL/Connection.php
View file @
c61361d8
...
...
@@ -562,13 +562,15 @@ class Connection implements DriverConnection
/**
* Executes an SQL DELETE statement on a table.
*
* @param string $tableName The name of the table on which to delete.
* Table expression and columns are not escaped and are not safe for user-input.
*
* @param string $tableExpression The expression of the table on which to delete.
* @param array $identifier The deletion criteria. An associative array containing column-value pairs.
* @param array $types The types of identifiers.
*
* @return integer The number of affected rows.
*/
public
function
delete
(
$table
Name
,
array
$identifier
,
array
$types
=
array
())
public
function
delete
(
$table
Expression
,
array
$identifier
,
array
$types
=
array
())
{
$this
->
connect
();
...
...
@@ -582,7 +584,7 @@ class Connection implements DriverConnection
$types
=
$this
->
extractTypeValues
(
$identifier
,
$types
);
}
$query
=
'DELETE FROM '
.
$table
Name
.
' WHERE '
.
implode
(
' AND '
,
$criteria
);
$query
=
'DELETE FROM '
.
$table
Expression
.
' WHERE '
.
implode
(
' AND '
,
$criteria
);
return
$this
->
executeUpdate
(
$query
,
array_values
(
$identifier
),
$types
);
}
...
...
@@ -630,14 +632,16 @@ class Connection implements DriverConnection
/**
* Executes an SQL UPDATE statement on a table.
*
* @param string $tableName The name of the table to update.
* Table expression and columns are not escaped and are not safe for user-input.
*
* @param string $tableExpression The expression of the table to update quoted or unquoted.
* @param array $data An associative array containing column-value pairs.
* @param array $identifier The update criteria. An associative array containing column-value pairs.
* @param array $types Types of the merged $data and $identifier arrays in that order.
*
* @return integer The number of affected rows.
*/
public
function
update
(
$table
Name
,
array
$data
,
array
$identifier
,
array
$types
=
array
())
public
function
update
(
$table
Expression
,
array
$data
,
array
$identifier
,
array
$types
=
array
())
{
$this
->
connect
();
$set
=
array
();
...
...
@@ -652,7 +656,7 @@ class Connection implements DriverConnection
$params
=
array_merge
(
array_values
(
$data
),
array_values
(
$identifier
));
$sql
=
'UPDATE '
.
$table
Name
.
' SET '
.
implode
(
', '
,
$set
)
$sql
=
'UPDATE '
.
$table
Expression
.
' SET '
.
implode
(
', '
,
$set
)
.
' WHERE '
.
implode
(
' = ? AND '
,
array_keys
(
$identifier
))
.
' = ?'
;
...
...
@@ -662,22 +666,24 @@ class Connection implements DriverConnection
/**
* Inserts a table row with specified data.
*
* @param string $tableName The name of the table to insert data into.
* Table expression and columns are not escaped and are not safe for user-input.
*
* @param string $tableExpression The expression of the table to insert data into, quoted or unquoted.
* @param array $data An associative array containing column-value pairs.
* @param array $types Types of the inserted data.
*
* @return integer The number of affected rows.
*/
public
function
insert
(
$table
Name
,
array
$data
,
array
$types
=
array
())
public
function
insert
(
$table
Expression
,
array
$data
,
array
$types
=
array
())
{
$this
->
connect
();
if
(
empty
(
$data
))
{
return
$this
->
executeUpdate
(
'INSERT INTO '
.
$table
Name
.
' ()'
.
' VALUES ()'
);
return
$this
->
executeUpdate
(
'INSERT INTO '
.
$table
Expression
.
' ()'
.
' VALUES ()'
);
}
return
$this
->
executeUpdate
(
'INSERT INTO '
.
$table
Name
.
' ('
.
implode
(
', '
,
array_keys
(
$data
))
.
')'
.
'INSERT INTO '
.
$table
Expression
.
' ('
.
implode
(
', '
,
array_keys
(
$data
))
.
')'
.
' VALUES ('
.
implode
(
', '
,
array_fill
(
0
,
count
(
$data
),
'?'
))
.
')'
,
array_values
(
$data
),
is_string
(
key
(
$types
))
?
$this
->
extractTypeValues
(
$data
,
$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