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);
php symfony doctrine
|
show 2 more comments
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);
php symfony doctrine
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
|
show 2 more comments
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);
php symfony doctrine
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
php symfony doctrine
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
|
show 2 more comments
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
|
show 2 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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