View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0007177 | OXID eShop (all versions) | 4.01. Database handling | public | 2020-09-24 13:20 | 2020-09-25 09:35 |
Reporter | wael golli | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | open | ||
Product Version | 6.2.2 | ||||
Summary | 0007177: Doctrine QueryBuilder INSERT | ||||
Description | Using Doctrine QuerBuilder to insert a new row using an array of values,fails and throws Syntax error, Values should be treated and checked | ||||
Steps To Reproduce | 1/create a new Array() contains different values of int/date/strings, it can be empty values 2/ use query builder as described below $queryBuilder ->insert( ' TableName ' ) ->values( $aKeyValues ); | ||||
Additional Information | 3/ generated SQL : INSERT INTO Table name (Name1,Name2,Name3...) VALUES(94, ,Val3 ... ) 4/ this SQL throws error empty string should be ' ' | ||||
Tags | Database, doctrine, MySQL, QueryBuilder | ||||
Theme | Not defined | ||||
Browser | Not defined | ||||
PHP Version | 7.1 | ||||
Database Version | MySQL 5.5 | ||||
|
Dear Wael Golli, i cannot reproduce the same failure msg. I created querys according to https://www.doctrine-project.org/projects/doctrine-dbal/en/2.10/reference/query-builder.html#values-clause Could you please provide your query in a whole? Best Regards QA - SG - |
|
Dear QA, Ill write for you some testing data and steps to reproduce it: 1/ $var1=' ';$var2='2020-01-02 18:30:00';$var3='(45)test(23)'; $aList={ "columnA" => $var1, "columnB"=> $var2, "columnC3=>$var3 } 2) $queryBuilder ->insert( ' TableTest ' ) ->values( $aList ); 3) the query generated would be = INSERT INTO TableTest( ColumnA,ColumnB,ColumnC) VALUES ( ,2020-01-02 18:30:00, (45)test(23)) executing this query would give an exception, |
|
Hey Wael Golli, this is expected behaviour from Doctrine DBAL. If you'd like to insert the values via the call to values() directly, you need to prepare those values on your own, alternatively bind those values via calls to setParameter(). Your code could look like this: $var1 = ' '; $var2 = '2020-01-02 18:30:00'; $var3 = '(45)test(23)'; $list= [ "columnA" => "?", "columnB" => "?", "columnC" => "?" ]; $queryBuilder->insert('TableTest') ->values($list) ->setParameter(0, $var1) ->setParameter(1, $var2) ->setParameter(2, $var3); You can find out more on this topic in the official Doctrine documentation at https://www.doctrine-project.org/projects/doctrine-dbal/en/2.10/reference/query-builder.html#values-clause Hope I could help Florian |
|
Dear Wael Golli, as Florian explained: We use the original syntax of doctrine, please check the references. Best Regards QA -SG- |