public function downloadcsvAction()
{
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
$query=Engine_Db_Table::getDefaultAdapter()->select()
->from(‘engine4_users’,array(‘user_id’,’email’,’displayname’,’level_id’,’enabled’,’approved’,’creation_date’))
->where(‘user_id !=?’,1)
->where(‘user_id not in (?)’, array(‘685′,’870′,’948′,’965′,’1031′,’1249′,’1279′,’1283’));
$aResult= $query->query()->fetchAll();
header(‘Content-Type: application/csv’);
header(‘Content-Disposition: attachement; filename=”users.csv”‘);
$f = fopen(‘php://output’, ‘w’) or show_error(“Can’t open php://output”);
$n = 0;$line = array();$array=array();
$line[]=’Email’; $line[]=’Display Name’;
$array[]=$line;
$line[]=’info@smarttips.in’;$line[‘sijo’];
$array[] = $line;
}
foreach ($array as $user)
{
$n++;
if (!fputcsv($f, $user))
{
show_error(“Can’t write line $n: $user”);
}
}
fclose($f) or show_error(“Can’t close php://output”);
}