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
b346106c
Commit
b346106c
authored
Jul 02, 2015
by
Martin Prebio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RunSqlCommand: Adding --fetch-result option
parent
4a9119b8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
RunSqlCommand.php
lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php
+3
-2
RunSqlCommandTest.php
...s/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php
+14
-0
No files found.
lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php
View file @
b346106c
...
...
@@ -48,7 +48,8 @@ class RunSqlCommand extends Command
->
setDescription
(
'Executes arbitrary SQL directly from the command line.'
)
->
setDefinition
(
array
(
new
InputArgument
(
'sql'
,
InputArgument
::
REQUIRED
,
'The SQL statement to execute.'
),
new
InputOption
(
'depth'
,
null
,
InputOption
::
VALUE_REQUIRED
,
'Dumping depth of result set.'
,
7
)
new
InputOption
(
'depth'
,
null
,
InputOption
::
VALUE_REQUIRED
,
'Dumping depth of result set.'
,
7
),
new
InputOption
(
'fetch-result'
,
null
,
InputOption
::
VALUE_NONE
,
'Forces fetching the result.'
),
))
->
setHelp
(
<<<EOT
Executes arbitrary SQL directly from the command line.
...
...
@@ -73,7 +74,7 @@ EOT
throw
new
\LogicException
(
"Option 'depth' must contains an integer value"
);
}
if
(
stripos
(
$sql
,
'select'
)
===
0
)
{
if
(
stripos
(
$sql
,
'select'
)
===
0
||
$input
->
getOption
(
'fetch-result'
)
)
{
$resultSet
=
$conn
->
fetchAll
(
$sql
);
}
else
{
$resultSet
=
$conn
->
executeUpdate
(
$sql
);
...
...
tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php
View file @
b346106c
...
...
@@ -106,4 +106,18 @@ class RunSqlCommandTest extends \PHPUnit_Framework_TestCase
->
expects
(
$this
->
exactly
(
1
))
->
method
(
'fetchAll'
);
}
public
function
testStatementsWithFetchResultPrintsResult
()
{
$this
->
expectConnectionFetchAll
();
$this
->
commandTester
->
execute
(
array
(
'command'
=>
$this
->
command
->
getName
(),
'sql'
=>
'"WITH bar as (SELECT 1) SELECT * FROM bar'
,
'--fetch-result'
=>
true
,
));
$this
->
assertRegExp
(
'@int.*1.*@'
,
$this
->
commandTester
->
getDisplay
());
$this
->
assertRegExp
(
'@array.*1.*@'
,
$this
->
commandTester
->
getDisplay
());
}
}
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