Skip to content
GitLab
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
dc498ecc
Commit
dc498ecc
authored
Oct 11, 2020
by
Marc Egger
Browse files
SqlQuery.php: allow insert empty record
parent
6e25f346
Pipeline
#3975
failed with stages
in 3 minutes and 44 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
extension/Classes/Core/Helper/SqlQuery.php
View file @
dc498ecc
...
...
@@ -37,9 +37,8 @@ class SqlQuery {
}
/**
* Create SQL query which inserts the values of the given associative arry into the given table.
* Create SQL query which inserts the values of the given associative arr
a
y into the given table.
* Returns prepared INSERT statement together with a parameter array.
* There must be at least one value given.
*
* @param $tableName
* @param array $values array(column => value)
...
...
@@ -48,12 +47,14 @@ class SqlQuery {
*/
public
static
function
insertRecord
(
$tableName
,
array
$values
):
array
{
if
(
count
(
$values
)
===
0
)
throw
new
\
CodeException
(
'No columns given to insert - this should not happen.'
,
ERROR_CODE_SHOULD_NOT_HAPPEN
);
if
(
count
(
$values
)
===
0
)
{
$sql
=
"INSERT INTO `
$tableName
` VALUES ()"
;
return
array
(
$sql
,
[]);
}
$paramList
=
str_repeat
(
'?, '
,
count
(
$values
));
$paramList
=
substr
(
$paramList
,
0
,
strlen
(
$paramList
)
-
2
);
$columnList
=
'`'
.
implode
(
'`, `'
,
array_keys
(
$values
))
.
'`'
;
$sql
=
"INSERT INTO `
$tableName
` (
"
.
$columnList
.
"
) VALUES (
"
.
$paramList
.
' )'
;
$sql
=
"INSERT INTO `
$tableName
` (
$columnList
) VALUES (
$paramList
)"
;
$parameterArray
=
array_values
(
$values
);
return
array
(
$sql
,
$parameterArray
);
}
...
...
extension/Classes/Core/QuickFormQuery.php
View file @
dc498ecc
...
...
@@ -456,8 +456,8 @@ class QuickFormQuery {
// FormAsFile: Get the new and the old form file name and make sure both files are writable (before DB changes are made)
// Note: This can't be done earlier because $formModeNew might be changed in the lines above.
$formNameDB
=
FormAsFile
::
formNameFromFormRelatedRecord
(
$recordId
,
$this
->
formSpec
[
F_TABLE_NAME
],
$this
->
dbArray
[
$this
->
dbIndexQfq
]);
switch
(
$this
->
formSpec
[
F_TABLE_NAME
])
{
$formNameDB
=
FormAsFile
::
formNameFromFormRelatedRecord
(
$recordId
,
$this
->
formSpec
[
F_TABLE_NAME
]
??
''
,
$this
->
dbArray
[
$this
->
dbIndexQfq
]);
switch
(
$this
->
formSpec
[
F_TABLE_NAME
]
??
''
)
{
case
TABLE_NAME_FORM
:
// cases covered: new form, existing form, existing form but form name changed
$formFileName
=
$this
->
store
->
getVar
(
F_NAME
,
STORE_FORM
,
SANITIZE_ALLOW_ALNUMX
);
$formFileName
=
$formFileName
===
false
?
$formNameDB
:
$formFileName
;
...
...
@@ -683,7 +683,7 @@ class QuickFormQuery {
FormAsFile
::
exportForm
(
$formFileName
,
$this
->
dbArray
[
$this
->
dbIndexQfq
]);
break
;
case
FORM_DELETE
:
if
(
TABLE_NAME_FORM_ELEMENT
===
$this
->
formSpec
[
F_TABLE_NAME
])
{
if
(
TABLE_NAME_FORM_ELEMENT
===
(
$this
->
formSpec
[
F_TABLE_NAME
]
??
''
)
)
{
FormAsFile
::
exportForm
(
$formFileName
,
$this
->
dbArray
[
$this
->
dbIndexQfq
]);
}
else
{
FormAsFile
::
deleteFormFile
(
$formFileName
,
$this
->
dbArray
[
$this
->
dbIndexQfq
]);
...
...
@@ -1743,8 +1743,8 @@ class QuickFormQuery {
$beUserLoggedIn
=
$this
->
store
->
getVar
(
TYPO3_BE_USER
,
STORE_TYPO3
,
SANITIZE_ALLOW_ALNUMX
);
if
(
$beUserLoggedIn
&&
$this
->
inlineReport
)
{
$html
.
=
$this
->
buildInlineReport
(
$this
->
t3data
[
T3DATA_UID
],
$this
->
t3data
[
T3DATA_REPORT_PATH_FILENAME
],
$this
->
t3data
[
T3DATA_BODYTEXT_RAW
],
$this
->
t3data
[
T3DATA_HEADER
]);
$html
.
=
$this
->
buildInlineReport
(
$this
->
t3data
[
T3DATA_UID
]
??
null
,
$this
->
t3data
[
T3DATA_REPORT_PATH_FILENAME
]
??
null
,
$this
->
t3data
[
T3DATA_BODYTEXT_RAW
]
??
''
,
$this
->
t3data
[
T3DATA_HEADER
]
??
''
);
}
$html
.
=
$report
->
process
(
$this
->
t3data
[
T3DATA_BODYTEXT
]);
...
...
extension/Classes/Core/Save.php
View file @
dc498ecc
...
...
@@ -447,7 +447,7 @@ class Save {
* @param int $recordId
* @param string $primaryKey
*
* @return bool|int false if $values is empty, else affectedrows
* @return bool|int false if $values is empty, else affected
rows
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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