Each report allows you to select whether to paginate or not. If you chose not to paginate, you can run UPDATE and INSERT queries.
-----------
Features
+* Pagination selection available fore reports
* You can configure reports db, schema and table names
Bugs
* the functions provided by the database driver exclusively, and hence
* will work with any database without modification.
*
- * $Id: Reports.php,v 1.17 2007/04/14 08:00:03 mr-russ Exp $
+ * $Id: Reports.php,v 1.18 2007/04/16 11:02:35 mr-russ Exp $
*/
class Reports {
else $filter = $ops = array();
$sql = $this->driver->getSelectSQL($this->reports_table,
- array('report_id', 'report_name', 'db_name', 'date_created', 'created_by', 'descr', 'report_sql'),
+ array('report_id', 'report_name', 'db_name', 'date_created', 'created_by', 'descr', 'report_sql', 'paginate'),
$filter, $ops, array('db_name' => 'asc', 'report_name' => 'asc'));
return $this->driver->selectSet($sql);
*/
function getReport($report_id) {
$sql = $this->driver->getSelectSQL($this->reports_table,
- array('report_id', 'report_name', 'db_name', 'date_created', 'created_by', 'descr', 'report_sql'),
+ array('report_id', 'report_name', 'db_name', 'date_created', 'created_by', 'descr', 'report_sql', 'paginate'),
array('report_id' => $report_id), array('report_id' => '='), array());
return $this->driver->selectSet($sql);
* @param $db_name The name of the database
* @param $descr The comment on the report
* @param $report_sql The SQL for the report
+ * @param $paginate The report should be paginated
* @return 0 success
*/
- function createReport($report_name, $db_name, $descr, $report_sql) {
+ function createReport($report_name, $db_name, $descr, $report_sql, $paginate) {
global $misc;
$server_info = $misc->getServerInfo();
$temp = array(
'report_name' => $report_name,
'db_name' => $db_name,
'created_by' => $server_info['username'],
- 'report_sql' => $report_sql
+ 'report_sql' => $report_sql,
+ 'paginate' => $paginate ? 'true' : 'false',
);
if ($descr != '') $temp['descr'] = $descr;
* @param $db_name The name of the database
* @param $descr The comment on the report
* @param $report_sql The SQL for the report
+ * @param $paginate The report should be paginated
* @return 0 success
*/
- function alterReport($report_id, $report_name, $db_name, $descr, $report_sql) {
+ function alterReport($report_id, $report_name, $db_name, $descr, $report_sql, $paginate) {
global $misc;
$server_info = $misc->getServerInfo();
$temp = array(
'db_name' => $db_name,
'created_by' => $server_info['username'],
'report_sql' => $report_sql,
+ 'paginate' => $paginate ? 'true' : 'false',
'descr' => $descr
);
/**
* List reports in a database
*
- * $Id: reports.php,v 1.24 2007/01/26 17:55:42 soranzo Exp $
+ * $Id: reports.php,v 1.25 2007/04/16 11:02:36 mr-russ Exp $
*/
// Include application functions
$_POST['db_name'] = $report->fields['db_name'];
$_POST['descr'] = $report->fields['descr'];
$_POST['report_sql'] = $report->fields['report_sql'];
+ if ($report->fields['paginate'] == 't') {
+ $_POST['paginate'] = TRUE;
+ }
}
// Get a list of available databases
echo "<td class=\"data1\"><textarea style=\"width:100%;\" rows=\"15\" cols=\"50\" name=\"report_sql\">",
htmlspecialchars($_POST['report_sql']), "</textarea></td></tr>\n";
echo "</table>\n";
+ echo "<label for=\"paginate\"><input type=\"checkbox\" id=\"paginate\" name=\"paginate\"", (isset($_POST['paginate']) ? ' checked="checked"' : ''), " /> {$lang['strpaginate']}</label>\n";
echo "<p><input type=\"hidden\" name=\"action\" value=\"save_edit\" />\n";
echo "<input type=\"submit\" value=\"{$lang['strsave']}\" />\n";
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n";
elseif ($_POST['report_sql'] == '') doEdit($lang['strreportneedsdef']);
else {
$status = $reportsdb->alterReport($_POST['report_id'], $_POST['report_name'], $_POST['db_name'],
- $_POST['descr'], $_POST['report_sql']);
+ $_POST['descr'], $_POST['report_sql'], isset($_POST['paginate']));
if ($status == 0)
doDefault($lang['strreportcreated']);
else
echo "<td class=\"data1\"><textarea style=\"width:100%;\" rows=\"15\" cols=\"50\" name=\"report_sql\">",
htmlspecialchars($_REQUEST['report_sql']), "</textarea></td></tr>\n";
echo "</table>\n";
+ echo "<label for=\"paginate\"><input type=\"checkbox\" id=\"paginate\" name=\"paginate\"", (isset($_REQUEST['paginate']) ? ' checked="checked"' : ''), " /> {$lang['strpaginate']}</label>\n";
echo "<p><input type=\"hidden\" name=\"action\" value=\"save_create\" />\n";
echo "<input type=\"submit\" value=\"{$lang['strsave']}\" />\n";
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n";
elseif ($_POST['report_sql'] == '') doCreate($lang['strreportneedsdef']);
else {
$status = $reportsdb->createReport($_POST['report_name'], $_POST['db_name'],
- $_POST['descr'], $_POST['report_sql']);
+ $_POST['descr'], $_POST['report_sql'], isset($_POST['paginate']));
if ($status == 0)
doDefault($lang['strreportcreated']);
else
$misc->printMsg($msg);
$reports = $reportsdb->getReports();
-
+
$columns = array(
'report' => array(
'title' => $lang['strreport'],
),
'run' => array(
'title' => $lang['strrun'],
- 'url' => "display.php?subject=report&{$misc->href}&return_url={$return_url}&return_desc=".urlencode($lang['strback'])."&",
- 'vars' => array('report' => 'report_name', 'database' => 'db_name', 'query' => 'report_sql'),
+ 'url' => "sql.php?subject=report&{$misc->href}&return_url={$return_url}&return_desc=".urlencode($lang['strback'])."&",
+ 'vars' => array('report' => 'report_name', 'database' => 'db_name', 'query' => 'report_sql', 'paginate' => 'paginate'),
),
'edit' => array(
'title' => $lang['stredit'],
* how many SQL statements have been strung together with semi-colons
* @param $query The SQL query string to execute
*
- * $Id: sql.php,v 1.33 2007/01/10 01:31:18 soranzo Exp $
+ * $Id: sql.php,v 1.34 2007/04/16 11:02:36 mr-russ Exp $
*/
// Prevent timeouts on large exports (non-safe mode only)
$_REQUEST['query'] = $_POST['query'];
}
+ // Pagination maybe set by a get link that has it as FALSE,
+ // if that's the case, unset the variable.
+
+ if (isset($_REQUEST['paginate']) && $_REQUEST['paginate'] == 'f') {
+ unset($_REQUEST['paginate']);
+ unset($_POST['paginate']);
+ unset($_GET['paginate']);
+ }
// Check to see if pagination has been specified. In that case, send to display
// script for pagination
- if (isset($_POST['paginate']) && !isset($_POST['explain']) && !isset($_POST['explain_analyze'])) {
+ if (isset($_REQUEST['paginate']) && !isset($_REQUEST['explain']) && !isset($_REQUEST['explain_analyze'])) {
include('./display.php');
exit;
}
else {
// Set fetch mode to NUM so that duplicate field names are properly returned
$data->conn->setFetchMode(ADODB_FETCH_NUM);
- $rs = $data->conn->Execute($_POST['query']);
+ $rs = $data->conn->Execute($_REQUEST['query']);
// $rs will only be an object if there is no error
if (is_object($rs)) {
echo "<p>{$lang['strsqlexecuted']}</p>\n";
echo "<p><a class=\"navlink\" href=\"database.php?database=", urlencode($_REQUEST['database']),
- "&server=", urlencode($_REQUEST['server']), "&action=sql&query=", urlencode($_POST['query']), "\">{$lang['streditsql']}</a>";
+ "&server=", urlencode($_REQUEST['server']), "&action=sql&query=", urlencode($_REQUEST['query']), "\">{$lang['streditsql']}</a>";
if ($conf['show_reports'] && isset($rs) && is_object($rs) && $rs->recordCount() > 0) {
echo " | <a class=\"navlink\" href=\"reports.php?{$misc->href}&action=create&report_sql=",
- urlencode($_POST['query']), "\">{$lang['strcreatereport']}</a>";
+ urlencode($_REQUEST['query']), "\">{$lang['strcreatereport']}</a>";
}
echo "</p>\n";
--
-- To run, type: psql template1 < reports-pgsql.sql
--
--- $Id: reports-pgsql.sql,v 1.3 2003/10/23 08:32:20 chriskl Exp $
+-- $Id: reports-pgsql.sql,v 1.4 2007/04/16 11:02:36 mr-russ Exp $
CREATE DATABASE phppgadmin;
created_by varchar(255) NOT NULL,
descr text,
report_sql text NOT NULL,
+ paginate boolean NOT NULL,
PRIMARY KEY (report_id)
);