Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
UserAdminV2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
UserAdminV2
Commits
559785f1
Commit
559785f1
authored
Oct 12, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added increment method to query builder.
parent
68455378
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
laravel/database/grammars/grammar.php
+4
-4
laravel/database/query.php
+12
-0
No files found.
laravel/database/grammars/grammar.php
View file @
559785f1
...
@@ -325,7 +325,7 @@ class Grammar {
...
@@ -325,7 +325,7 @@ class Grammar {
* @param array $columns
* @param array $columns
* @return string
* @return string
*/
*/
p
rotected
function
columnize
(
$columns
)
p
ublic
function
columnize
(
$columns
)
{
{
return
implode
(
', '
,
array_map
(
array
(
$this
,
'wrap'
),
$columns
));
return
implode
(
', '
,
array_map
(
array
(
$this
,
'wrap'
),
$columns
));
}
}
...
@@ -340,7 +340,7 @@ class Grammar {
...
@@ -340,7 +340,7 @@ class Grammar {
* @param string $value
* @param string $value
* @return string
* @return string
*/
*/
p
rotected
function
wrap
(
$value
)
p
ublic
function
wrap
(
$value
)
{
{
if
(
strpos
(
strtolower
(
$value
),
' as '
)
!==
false
)
return
$this
->
alias
(
$value
);
if
(
strpos
(
strtolower
(
$value
),
' as '
)
!==
false
)
return
$this
->
alias
(
$value
);
...
@@ -376,7 +376,7 @@ class Grammar {
...
@@ -376,7 +376,7 @@ class Grammar {
* @param array $values
* @param array $values
* @return string
* @return string
*/
*/
p
rotected
function
parameterize
(
$values
)
p
ublic
function
parameterize
(
$values
)
{
{
return
implode
(
', '
,
array_map
(
array
(
$this
,
'parameter'
),
$values
));
return
implode
(
', '
,
array_map
(
array
(
$this
,
'parameter'
),
$values
));
}
}
...
@@ -391,7 +391,7 @@ class Grammar {
...
@@ -391,7 +391,7 @@ class Grammar {
* @param mixed $value
* @param mixed $value
* @return string
* @return string
*/
*/
p
rotected
function
parameter
(
$value
)
p
ublic
function
parameter
(
$value
)
{
{
return
(
$value
instanceof
Expression
)
?
$value
->
get
()
:
'?'
;
return
(
$value
instanceof
Expression
)
?
$value
->
get
()
:
'?'
;
}
}
...
...
laravel/database/query.php
View file @
559785f1
...
@@ -582,6 +582,18 @@ class Query {
...
@@ -582,6 +582,18 @@ class Query {
}
}
/**
/**
* Increment the value of a column by a given amount.
*
* @param string $column
* @param int $amount
* @return int
*/
public
function
increment
(
$column
,
$amount
=
1
)
{
return
$this
->
update
(
array
(
$column
=>
Manager
::
raw
(
$this
->
grammar
->
wrap
(
$column
)
.
' + '
.
$amount
)));
}
/**
* Update an array of values in the database table.
* Update an array of values in the database table.
*
*
* @param array $values
* @param array $values
...
...
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