We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Howto create/write a file?

Hi

I'm trying to create a configuration file for a 3rd party program, from within my phalcon application..

The data is stored in the phalcon database..

The output data-format is basically:

[group1] item1 item2 option option

[group2] item3 option item4

Is there an easy way to do this???

Can you show us example code or table schema and expected result? I really dont understand your question at the moment.

I'll try to explain...

I have a table in the database (and have created a model based on this):

fields: id name option1 option2 option3 groupid

I need to get this written into a text/configuration file in the following manner:

[group1] 
item1 
item2 option option

[group2] 
item3 option 
item4

This is similiar to the Config/Ini class, but that's only for reading...

I could do this with fopen and fwrite and loop through the database entries... but I just want to know if there is a better way to do it...