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
a8d9830d
Commit
a8d9830d
authored
Nov 10, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added update() method, needed for various things but especially for the CTI implementation
parent
11ee8e33
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
3 deletions
+36
-3
Connection.php
lib/Doctrine/Connection.php
+36
-3
No files found.
lib/Doctrine/Connection.php
View file @
a8d9830d
...
...
@@ -501,6 +501,41 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
return
$affectedRows
;
}
/**
* Updates table row(s) with specified data
*
* @throws Doctrine_Connection_Exception if something went wrong at the database level
* @param string $table The table to insert data into
* @param array $values An associateve array containing column-value pairs.
* @return mixed boolean false if empty value array was given,
* otherwise returns the number of affected rows
*/
public
function
update
(
$table
,
array
$values
,
array
$identifier
)
{
if
(
empty
(
$values
))
{
return
false
;
}
$set
=
array
();
foreach
(
$values
as
$name
=>
$value
)
{
if
(
$value
instanceof
Doctrine_Expression
)
{
$set
[]
=
$name
.
' = '
.
$value
->
getSql
();
unset
(
$values
[
$name
]);
}
else
{
$set
[]
=
$name
.
' = ?'
;
}
}
$params
=
array_merge
(
array_values
(
$values
),
array_values
(
$identifier
));
$sql
=
'UPDATE '
.
$this
->
quoteIdentifier
(
$table
)
.
' SET '
.
implode
(
', '
,
$set
)
.
' WHERE '
.
implode
(
' = ? AND '
,
array_keys
(
$identifier
))
.
' = ?'
;
return
$this
->
exec
(
$sql
,
$params
);
}
/**
* Inserts a table row with specified data.
*
...
...
@@ -508,7 +543,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @param array $values An associateve array containing column-value pairs.
* @return boolean
*/
public
function
insert
(
$table
,
array
$values
=
array
()
)
{
public
function
insert
(
$table
,
array
$values
)
{
if
(
empty
(
$values
))
{
return
false
;
}
...
...
@@ -544,8 +579,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* Set the charset on the current connection
*
* @param string charset
*
* @return void
*/
public
function
setCharset
(
$charset
)
{
...
...
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