public function onGenerate($param) { try { $this->form->validate(); $data = $this->form->getData(); if (strtoupper(substr($data->select, 0, 6)) !== 'SELECT') { throw new Exception(_t('Invalid command')); } // creates a DataGrid $datagrid = new BootstrapDatagridWrapper(new TDataGrid()); $datagrid->style = 'width: 100%'; $datagrid->setHeight(320); TTransaction::open($data->database); $conn = TTransaction::get(); $result = $conn->query($data->select); $row = $result->fetch(); foreach ($row as $key => $value) { if (is_string($key)) { $col = new TDataGridColumn($key, $key, 'left'); $datagrid->addColumn($col); } } // create the datagrid model $datagrid->createModel(); $datagrid->addItem((object) $row); $i = 1; while ($row = $result->fetch() and $i <= 1000) { $datagrid->addItem((object) $row); $i++; } $panel = new TPanelGroup(_t('Results')); $panel->add($datagrid); $panel->addFooter(_t('^1 records shown', "<b>{$i}</b>")); $this->container->addRow()->addCell($panel); TTransaction::close(); } catch (Exception $e) { new TMessage('error', $e->getMessage()); } }