1

How do I store a complete array in database in symfony. My content of the array is a shopping cart:

article_id / article  / amount / price

example:

1 / knife / 4 / 4$
2 / for / 6 / 2$

How can I store the complete array in one cell?

Thanks in advance!

1

3 Answers 3

1

You may use the object column type of doctrine. This will serialize() and deserialize() your contents.

See: http://www.doctrine-project.org/documentation/manual/1_0/en/defining-models:columns:data-types#object

Sign up to request clarification or add additional context in comments.

Comments

1

You could serialize() the array before storing it in the database and use unserialize() after retrieving it.

Comments

1

Serialize() & unserialize() reference

http://www.tanzilo.com/2008/12/31/php-serialization-unserialization-explanation-code-example/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.