Array to string conversion error while passing an array to one of Entity's functions









up vote
-1
down vote

favorite












1) I created Question entity with field Tags of simple_array type:



 /**
* @ORMColumn(type="simple_array", nullable=true)
*/
private $Tags = ;

public function getTags(): ?array

return $this->Tags;


public function setTags(?array $Tags): self

$this->Tags = $Tags;

return $this;



2) When I want to create a Question object and initialize Tags field like that:



 $question = new Question();
$question
->setTags( array("1","2","3"));


then Symfony throws an error:



Array to string conversion


3) My question: Why is Symfony throwing the error and how can I fix it?



Is wrong typing cause of it?



EDIT: Doctrine Config:



parameters:
# Adds a fallback DATABASE_URL if the env var is not set.
# This allows you to run cache:warmup even if your
# environment variables are not available yet.
# You should not need to change this value.
env(DATABASE_URL): ''

doctrine:
dbal:
# configure these for your database server
driver: 'pdo_mysql'
server_version: '5.8'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci

url: '%env(resolve:DATABASE_URL)%'
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'AppEntity'
alias: App


mysql Ver 15.1 Distrib 10.1.36-MariaDB, for Win32 (AMD64)



EDIT:



in vendordoctrinedballibDoctrineDBALDriverPDOStatement.php (line 102)

public function bindValue($param, $value, $type = ParameterType::STRING)

$type = $this->convertParamType($type);
try
return parent::bindValue($param, $value, $type);
catch (PDOException $exception)
throw new PDOException($exception);











share|improve this question























  • I'm assuming you must use a comma delimited string, as specified in the documentation.
    – Andrei
    Nov 11 at 13:35










  • Could you verify that you have this class: /vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/SimpleArrayType.php !!
    – Ahmed bhs
    Nov 11 at 14:10










  • Could you provide your doctrine configuration plz !
    – Ahmed bhs
    Nov 11 at 14:24






  • 1




    Can you show where it throws the error, i.e. which code you execute when the error happens? The entity and the small example look fine to me.
    – dbrumann
    Nov 11 at 15:52






  • 1




    Where does Symfony throw that? Share complete error message with file & line number
    – Trix
    Nov 11 at 16:29














up vote
-1
down vote

favorite












1) I created Question entity with field Tags of simple_array type:



 /**
* @ORMColumn(type="simple_array", nullable=true)
*/
private $Tags = ;

public function getTags(): ?array

return $this->Tags;


public function setTags(?array $Tags): self

$this->Tags = $Tags;

return $this;



2) When I want to create a Question object and initialize Tags field like that:



 $question = new Question();
$question
->setTags( array("1","2","3"));


then Symfony throws an error:



Array to string conversion


3) My question: Why is Symfony throwing the error and how can I fix it?



Is wrong typing cause of it?



EDIT: Doctrine Config:



parameters:
# Adds a fallback DATABASE_URL if the env var is not set.
# This allows you to run cache:warmup even if your
# environment variables are not available yet.
# You should not need to change this value.
env(DATABASE_URL): ''

doctrine:
dbal:
# configure these for your database server
driver: 'pdo_mysql'
server_version: '5.8'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci

url: '%env(resolve:DATABASE_URL)%'
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'AppEntity'
alias: App


mysql Ver 15.1 Distrib 10.1.36-MariaDB, for Win32 (AMD64)



EDIT:



in vendordoctrinedballibDoctrineDBALDriverPDOStatement.php (line 102)

public function bindValue($param, $value, $type = ParameterType::STRING)

$type = $this->convertParamType($type);
try
return parent::bindValue($param, $value, $type);
catch (PDOException $exception)
throw new PDOException($exception);











share|improve this question























  • I'm assuming you must use a comma delimited string, as specified in the documentation.
    – Andrei
    Nov 11 at 13:35










  • Could you verify that you have this class: /vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/SimpleArrayType.php !!
    – Ahmed bhs
    Nov 11 at 14:10










  • Could you provide your doctrine configuration plz !
    – Ahmed bhs
    Nov 11 at 14:24






  • 1




    Can you show where it throws the error, i.e. which code you execute when the error happens? The entity and the small example look fine to me.
    – dbrumann
    Nov 11 at 15:52






  • 1




    Where does Symfony throw that? Share complete error message with file & line number
    – Trix
    Nov 11 at 16:29












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











1) I created Question entity with field Tags of simple_array type:



 /**
* @ORMColumn(type="simple_array", nullable=true)
*/
private $Tags = ;

public function getTags(): ?array

return $this->Tags;


public function setTags(?array $Tags): self

$this->Tags = $Tags;

return $this;



2) When I want to create a Question object and initialize Tags field like that:



 $question = new Question();
$question
->setTags( array("1","2","3"));


then Symfony throws an error:



Array to string conversion


3) My question: Why is Symfony throwing the error and how can I fix it?



Is wrong typing cause of it?



EDIT: Doctrine Config:



parameters:
# Adds a fallback DATABASE_URL if the env var is not set.
# This allows you to run cache:warmup even if your
# environment variables are not available yet.
# You should not need to change this value.
env(DATABASE_URL): ''

doctrine:
dbal:
# configure these for your database server
driver: 'pdo_mysql'
server_version: '5.8'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci

url: '%env(resolve:DATABASE_URL)%'
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'AppEntity'
alias: App


mysql Ver 15.1 Distrib 10.1.36-MariaDB, for Win32 (AMD64)



EDIT:



in vendordoctrinedballibDoctrineDBALDriverPDOStatement.php (line 102)

public function bindValue($param, $value, $type = ParameterType::STRING)

$type = $this->convertParamType($type);
try
return parent::bindValue($param, $value, $type);
catch (PDOException $exception)
throw new PDOException($exception);











share|improve this question















1) I created Question entity with field Tags of simple_array type:



 /**
* @ORMColumn(type="simple_array", nullable=true)
*/
private $Tags = ;

public function getTags(): ?array

return $this->Tags;


public function setTags(?array $Tags): self

$this->Tags = $Tags;

return $this;



2) When I want to create a Question object and initialize Tags field like that:



 $question = new Question();
$question
->setTags( array("1","2","3"));


then Symfony throws an error:



Array to string conversion


3) My question: Why is Symfony throwing the error and how can I fix it?



Is wrong typing cause of it?



EDIT: Doctrine Config:



parameters:
# Adds a fallback DATABASE_URL if the env var is not set.
# This allows you to run cache:warmup even if your
# environment variables are not available yet.
# You should not need to change this value.
env(DATABASE_URL): ''

doctrine:
dbal:
# configure these for your database server
driver: 'pdo_mysql'
server_version: '5.8'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci

url: '%env(resolve:DATABASE_URL)%'
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'AppEntity'
alias: App


mysql Ver 15.1 Distrib 10.1.36-MariaDB, for Win32 (AMD64)



EDIT:



in vendordoctrinedballibDoctrineDBALDriverPDOStatement.php (line 102)

public function bindValue($param, $value, $type = ParameterType::STRING)

$type = $this->convertParamType($type);
try
return parent::bindValue($param, $value, $type);
catch (PDOException $exception)
throw new PDOException($exception);








php symfony doctrine






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 14:46

























asked Nov 11 at 13:15









Maciek

43




43











  • I'm assuming you must use a comma delimited string, as specified in the documentation.
    – Andrei
    Nov 11 at 13:35










  • Could you verify that you have this class: /vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/SimpleArrayType.php !!
    – Ahmed bhs
    Nov 11 at 14:10










  • Could you provide your doctrine configuration plz !
    – Ahmed bhs
    Nov 11 at 14:24






  • 1




    Can you show where it throws the error, i.e. which code you execute when the error happens? The entity and the small example look fine to me.
    – dbrumann
    Nov 11 at 15:52






  • 1




    Where does Symfony throw that? Share complete error message with file & line number
    – Trix
    Nov 11 at 16:29
















  • I'm assuming you must use a comma delimited string, as specified in the documentation.
    – Andrei
    Nov 11 at 13:35










  • Could you verify that you have this class: /vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/SimpleArrayType.php !!
    – Ahmed bhs
    Nov 11 at 14:10










  • Could you provide your doctrine configuration plz !
    – Ahmed bhs
    Nov 11 at 14:24






  • 1




    Can you show where it throws the error, i.e. which code you execute when the error happens? The entity and the small example look fine to me.
    – dbrumann
    Nov 11 at 15:52






  • 1




    Where does Symfony throw that? Share complete error message with file & line number
    – Trix
    Nov 11 at 16:29















I'm assuming you must use a comma delimited string, as specified in the documentation.
– Andrei
Nov 11 at 13:35




I'm assuming you must use a comma delimited string, as specified in the documentation.
– Andrei
Nov 11 at 13:35












Could you verify that you have this class: /vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/SimpleArrayType.php !!
– Ahmed bhs
Nov 11 at 14:10




Could you verify that you have this class: /vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/SimpleArrayType.php !!
– Ahmed bhs
Nov 11 at 14:10












Could you provide your doctrine configuration plz !
– Ahmed bhs
Nov 11 at 14:24




Could you provide your doctrine configuration plz !
– Ahmed bhs
Nov 11 at 14:24




1




1




Can you show where it throws the error, i.e. which code you execute when the error happens? The entity and the small example look fine to me.
– dbrumann
Nov 11 at 15:52




Can you show where it throws the error, i.e. which code you execute when the error happens? The entity and the small example look fine to me.
– dbrumann
Nov 11 at 15:52




1




1




Where does Symfony throw that? Share complete error message with file & line number
– Trix
Nov 11 at 16:29




Where does Symfony throw that? Share complete error message with file & line number
– Trix
Nov 11 at 16:29

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249107%2farray-to-string-conversion-error-while-passing-an-array-to-one-of-entitys-funct%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249107%2farray-to-string-conversion-error-while-passing-an-array-to-one-of-entitys-funct%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto