Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
12d16838
Commit
12d16838
authored
Jan 28, 2016
by
Carsten Rose
Browse files
Database: sql() accepts a 'specificMessage', shown if there is an exception
parent
23e8fa90
Changes
1
Hide whitespace changes
Inline
Side-by-side
qfq/Database.php
View file @
12d16838
...
...
@@ -178,12 +178,14 @@ class Database {
* @param $sql
* @param $mode
*/
public
function
sql
(
$sql
,
$mode
=
ROW_REGULAR
,
array
$parameterArray
=
array
())
{
public
function
sql
(
$sql
,
$mode
=
ROW_REGULAR
,
array
$parameterArray
=
array
()
,
$specificMessage
=
''
)
{
// for error reporting in exception
if
(
$specificMessage
)
$specificMessage
.
=
" "
;
$count
=
$this
->
prepareExecute
(
$sql
,
$parameterArray
);
if
(
$count
===
false
)
{
throw
new
DbException
(
"No idea why this error happens - please take some time and check this:
$sql
"
,
ERROR_DB_GENERIC_CHECK
);
throw
new
DbException
(
$specificMessage
.
"No idea why this error happens - please take some time and check this:
$sql
"
,
ERROR_DB_GENERIC_CHECK
);
}
if
(
$mode
===
ROW_IMPLODE_ALL
)
{
...
...
@@ -199,11 +201,11 @@ class Database {
return
array
();
}
throw
new
DbException
(
"Expected one row, got nothing:
$sql
"
,
ERROR_DB_TOO_FEW_ROWS
);
throw
new
DbException
(
$specificMessage
.
"Expected one row, got nothing:
$sql
"
,
ERROR_DB_TOO_FEW_ROWS
);
}
if
(
$count
>
1
)
{
throw
new
DbException
(
"Expected one row, got
$count
rows:
$sql
"
,
ERROR_DB_TOO_MANY_ROWS
);
throw
new
DbException
(
$specificMessage
.
"Expected one row, got
$count
rows:
$sql
"
,
ERROR_DB_TOO_MANY_ROWS
);
}
return
$this
->
fetchOne
();
...
...
Write
Preview
Supports
Markdown
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