$products = Model_Products::find()->get(); $data = "name;price ;category\r\n"; foreach ($products as $product) { $data .= $product->name . ";"; $data .= $product->price . ";"; $data .= $product->category . ";"; $data .= "\r\n"; } if (file_exists(DOCROOT . 'assets/doc/report.csv')) { File::update(DOCROOT . 'assets/doc', 'report.csv', $data); } else { File::create(DOCROOT . 'assets/doc', 'report.csv', $data); chmod(DOCROOT . 'assets/doc/report.csv', 0777); }
It looks like you're new here. If you want to get involved, click one of these buttons!