最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

如何在symfony中導(dǎo)出為CSV文件中的數(shù)據(jù)

 更新時(shí)間:2011年10月06日 11:13:31   作者:  
如果您需要在symfony中將數(shù)據(jù)庫中的數(shù)據(jù)導(dǎo)出為CSV文件,試試這個(gè)
開始:
復(fù)制代碼 代碼如下:

public function executeRegistrantsToCsv(){

$id = $this->getRequestParameter('id');

$c = new Criteria();
$c->add(RegistrantPeer::EVENT_ID, $id);
$c->add(RegistrantPeer::STATUS, 1);
$this->aObjReg = RegistrantPeer::doSelect($c);

$this->forward404Unless($this->aObjReg);
$this->setlayout('csv');

$this->getResponse()->clearHttpHeaders();
$this->getResponse()->setHttpHeader('Content-Type', 'application/vnd.ms-excel');
$this->getResponse()->setHttpHeader('Content-Disposition', 'attachment; filename=registrants_report_event_' . $id . '.csv');

}

在模板registrantsToCsvSuccess.php:
復(fù)制代碼 代碼如下:

Title,Name,Email,Phone,Organisation,State,City,Country,Login Date,IpAddress
<? foreach($aObjReg as $r): ?>
<?= $r->getTitle() ?>,<?= $r->getName() ?>,<?= $r->getEmail() ?>,<?= $r->getPhone() ?>,<?= $r->getOrganisation() ?>,<?= $r->getState() ?>,<?= $r->getCity() ?>,<?= $r->getCountry() ?>,<?= $r->getLoginDate() ?>,<?= $r->getIpAddress() ?>,
<? endforeach ?>

in the templates/csv.php:
<?php echo $sf_data->getRaw('sf_content') ?>
From: http://blog.baddog.net.au/sonius/steve-sonius/how-to-export-data-as-a-csv-file-in-symfony/
If it doesn't work, try this:http://blog.baddog.net.au/sonius/steve-sonius/how-to-export-data-as-an-xls-or-csv-file-from-the-admin-generator-in-symfony-1-4/

相關(guān)文章

最新評論

乌兰县| 宝鸡市| 萨嘎县| 吉隆县| 桂平市| 通州区| 岳西县| 永新县| 南乐县| 通海县| 张北县| 台北市| 宜君县| 蒲江县| 洛阳市| 鲁山县| 衢州市| 通城县| 邹城市| 偃师市| 建湖县| 游戏| 安新县| 宁夏| 盐池县| 吴忠市| 宜丰县| 潞城市| 象州县| 嵊泗县| 芒康县| 宿州市| 长寿区| 林甸县| 阳东县| 西盟| 焦作市| 西吉县| 密山市| 焦作市| 巴楚县|