yiisoft / db

Yii Database Library
https://www.yiiframework.com/
BSD 3-Clause "New" or "Revised" License
134 stars 35 forks source link

Lazy parsing for `array`, `structured` and `json` types #892

Open Tigrov opened 3 weeks ago

Tigrov commented 3 weeks ago

Suggested to store in ArrayExpression, StructuredExpression and JsonExpression the string value retrieved from the database and convert it to an array or other PHP representation as the data is accessed.

This will save resources if the data is not used during execution.

Can be optionally.

samdark commented 3 weeks ago

Sounds good from a performance perspective. The only thing is that checks such as is_array would become instanceof ArrayResult or something alike.

Tigrov commented 3 weeks ago

Actually I think about ArrayExpression which already realizes ArrayAccess, Countable and IteratorAggregate interfaces and the check should be is_iterable().

samdark commented 3 weeks ago

Expression is logically an input. Not sure it is a good idea to reuse for results.