JSON DB in SQL Field as Model

Hi everyone,

So I’ve created the invoice model, and I’d like for the invoice items to be stored as a JSON array inside a field in the model.

Could someone please point me in the right direction. I’m not completely sure how this should be implemented.

Would it be possible to create an entire Model, or even a sub-model of sorts, that allows me to interface with the array DB?



If I understand you correctly than you want to store JSON in MySQL. I would highly recommend NOT to do that in an RDBMS as you’ll lose all the benefits of a relational system. Is there any reason that you don’t want to create separate tables for your data? It is possible, yes, via a TEXT field in MySQL but if you really want to store “nested documents” you should take a look at MongoDB or another noSQL database. They are made to store data as JSON. There’s a nice extension out there for Yii called MongoDB Suite