Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, March 29, 2024
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  Simple Example of Report Extension, Please

phpMyEdit Features     Simple Example of Report Extension, Please
Post new topic   Reply to topic   Goto page 1, 2  Next  
 
mcfatema     Joined: 17 Sep 2008   Posts: 4  
Post Posted: 2008-09-19 19:46
Back to top  Reply with quote     

I'm having no luck getting the report extension to work. Can anybody who has it working post a few snippets of code so I might see what I'm doing wrong?I currently get a whole host of errors when I try it...

Warning: array_keys() [function.array-keys]: The first argument should be an array in ...htdocs/TTnet/phpMyEdit/phpMyEdit-5.7.1/phpMyEdit.class.php on line 2926

Warning: Invalid argument supplied for foreach() in ...phpMyEdit/phpMyEdit-5.7.1/phpMyEdit.class.php on line 2926

 
mcfatema     Joined: 17 Sep 2008   Posts: 4  
Post Posted: 2008-09-20 20:04
Back to top  Reply with quote     

OK, I removed the HTML header from my script and that solved another problem I was having. Now I'm to a point where I get the following response...

MySQL error 1064
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1
--------------------------------------------------------------------------------

phpMyEdit error: database fetch error

My code looks simply like this and I'm passing the same opts as phpMyEditSetup created for my table:

require_once 'extensions/phpMyEdit-report.class.php';
new phpMyEdit_report($opts);

 
vrteach     Joined: 22 Oct 2008   Posts: 1  
Post Posted: 2008-10-23 15:14
Back to top  Reply with quote     

I just started looking at it. The reports extension has a date a couple of years older than the main application, so I expect that it has some problems with php5.

I've started with moving all the old global variables like
$HTTP_GET_VARS to the current names, like $_GET, but that has not yet been enough to fix the error.

Edit: Yes you need to change all of the old-style variables, or to make it backwards compatible use the method that was used in the main application.

But also, in version 1.11 of the reports extension, go to line 145 and change the code from:

'limit' => '1');

to:

'limit' => 'LIMIT 1');

I didn't learn this myself, but found it in:

http://opensource.platon.sk/forum/projects/viewtopic.php?t=7935

 
davidhy5     Joined: 09 Nov 2008   Posts: 2  
Post Posted: 2008-11-09 02:24
Back to top  Reply with quote     

Hello,

I too was trying to get this the report extension working. Building on the other posts, I did the following to get the extension to work:

1. copy phpMyEdit-report.class.php from the extension folder to the root with phpMyEdit.class.php - just to keep things simple
2. Renamed $HTTP_SERVER_VARS = $_SERVER
Renamed $HTTP_GET_VARS = $_GET
Renamed $HTTP_POST_VARS = $_POST
Changed limit => '1' to 'Limit 1'
Commented out global lines = //global $_POST (2)
//global $_GET (2)
//global $_SERVER (1)
in the file phpMyEdit-report.class.php
3. put the appropriate commands in place of the phpmyedit.class calls
4. Ran code and have working reports pages (tested several times before posting)

Thanks to all the previous contributors.

 
sagiben     Joined: 27 Jan 2009   Posts: 15  
Post Posted: 2009-04-30 15:02
Back to top  Reply with quote     

What do you mean by :
"3. put the appropriate commands in place of the phpmyedit.class calls " ?

Thanks.

 
davidhy5     Joined: 09 Nov 2008   Posts: 2  
Post Posted: 2009-04-30 16:24
Back to top  Reply with quote     

sagiben wrote:
What do you mean by :
"3. put the appropriate commands in place of the phpmyedit.class calls " ?

Thanks.




Insert the following:

// Now important call to phpMyEdit
require_once 'extensions/phpMyEdit-report.class.php';
new phpMyEdit_report($opts);

in place of "new phpMyEdit($opts);"

I am having to wipe my machine and redo it, so if you have more questions I will not be back online until Friday, May 1st 2009.

 
sagiben     Joined: 27 Jan 2009   Posts: 15  
Post Posted: 2009-05-01 07:11
Back to top  Reply with quote     

Thank you for the quick answer.
I made all the above modifications and I'm not quite sure how the reports should look and how should I use it.

Can you (or someone) post an example or give a link to a running website that uses this feature.

Thanks.

 
Skipper     Joined: 20 Aug 2009   Posts: 7  
Post Posted: 2009-08-20 11:55
Back to top  Reply with quote     

working PHP 5 code for phpMyEdit-report.class.php

Code:
<?php

/*
* phpMyEdit - instant MySQL table editor and code generator
*
* extensions/phpMyEdit-report.class.php - phpMyEdit report extension
* ____________________________________________________________
*
* Developed by Ondrej Jombik <nepto@platon.sk>
* Copyright (c) 2002-2006 Platon Group, http://platon.sk/
* All rights reserved.
*
* See README file for more information about this software.
* See COPYING file for license information.
*
* Download the latest version from
* http://platon.sk/projects/phpMyEdit/
*/

/* $Platon: phpMyEdit/extensions/phpMyEdit-report.class.php,v 1.13 2008-11-11 04:46:39 nepto Exp $ */

/* Extension TODO:

   - allow user to enable/disable particular field in reporting (maybe 'X' flag
     for indicating that field is forbidden is good idea)
   - support for ['help'] in select fields screen
   - make extension's option for selecting "Select fields" link or button
*/

require_once dirname(__FILE__).'/../phpMyEdit.class.php';

class phpMyEdit_report extends phpMyEdit
{

   function phpMyEdit_report($opts) /* {{{ */
   {
      $opts['options'] = 'L';
      $execute = 1;
      isset($opts['execute']) && $execute = $opts['execute'];
      $opts['execute'] = 0;
      parent::phpMyEdit($opts);
      $execute && $this->execute();
   } /* }}} */

   function make_language_labels($language) /* {{{ */
   {
      $ret = parent::make_language_labels($language);
      strlen($ret['Make report'])        <= 0 && $ret['Make report']        = 'Make report';
      strlen($ret['Select fields'])      <= 0 && $ret['Select fields']      = 'Select fields';
      strlen($ret['Records per screen']) <= 0 && $ret['Records per screen'] = 'Records per screen';
      return $ret;
   } /* }}} */

   function get_cgi_cookie_var($name, $default_value = null) /* {{{ */
   {
      $ret = $this->get_cgi_var($name, null);
      if ($ret === null) {
         global $HTTP_COOKIE_VARS;
         $ret = @$HTTP_COOKIE_VARS[$name.'_'.$this->tb.'_cookie'];
         if (! isset($ret)) {
            $ret = $default_value;
         }
      }
      return $ret;
   } /* }}} */

   function display_list_table_buttons($total_recs, $position) /* {{{ */
   {   /* This is mostly copy/paste from core class. */
      $listall = $this->inc <= 0; // Are we doing a listall?
      echo '<table class="',$this->getCSSclass('navigation', $position),'">',"\n";
      echo '<tr class="',$this->getCSSclass('navigation', $position),'">',"\n";
      echo '<td class="',$this->getCSSclass('buttons', $position),'">',"\n";
      echo '<input class="',$this->getCSSclass('fields-select', $position);
      echo '" type="submit" name="fields_select" value="',$this->labels['Select fields'],'">&nbsp;';
      // Note that <input disabled isn't valid HTML, but most browsers support it
      $disabled = ($this->fm > 0 && ! $listall) ? '' : ' disabled';
      echo '<input',$disabled,' class="',$this->getCSSclass('prev', $position);
      echo '" type="submit" name="',ltrim($disabled),'prev" value="',$this->labels['Prev'],'">&nbsp;';
      $disabled = ($this->fm + $this->inc < $total_recs && ! $listall) ? '' : ' disabled';
      echo '<input',$disabled,' class="',$this->getCSSclass('next', $position);
      echo '" type="submit" name="',ltrim($disabled),'next" value="',$this->labels['Next'],'">';
      // Message is now written here
      echo '</td>',"\n";
      if (strlen(@$this->message) > 0) {
         echo '<td class="',$this->getCSSclass('message', $position),'">',$this->message,'</td>',"\n";
      }
      // Display page and records statistics
      echo '<td class="',$this->getCSSclass('stats', $position),'">',"\n";
      if ($listall) {
         echo $this->labels['Page'],':&nbsp;1&nbsp;',$this->labels['of'],'&nbsp;1';
      } else {
         echo $this->labels['Page'],':&nbsp;',($this->fm / $this->inc) + 1;
         echo '&nbsp;',$this->labels['of'],'&nbsp;',max(1, ceil($total_recs / abs($this->inc)));
      }
      echo '&nbsp; ',$this->labels['Records'],':&nbsp;',$total_recs;
      echo '</td></tr></table>',"\n";
   } /* }}} */

   function display_report_selection_buttons($position) /* {{{ */
   {
      echo '<table class="',$this->getCSSclass('navigation', $position),'">',"\n";
      echo '<tr class="',$this->getCSSclass('navigation', $position),'">',"\n";
      echo '<td class="',$this->getCSSclass('buttons', $position),'">',"\n";
      echo '<input class="',$this->getCSSclass('make-report', $position);
      echo '" type="submit" name="prepare_filter" value="',$this->labels['Make report'],'">',"\n";
      echo '</td></tr></table>',"\n";
   } /* }}} */

   function get_select_fields_link() /* {{{ */
   {
      $link = '<a href="'.htmlspecialchars($this->page_name).'?fields_select=1';
      for ($i = 0; $i < count($table_cols); $i++) {
         $varname = 'qf'.$i;
         $value   = $this->get_cgi_cookie_var($varname);
         if (! empty($value)) {
            $link .= htmlspecialchars(
                  '&'.rawurlencode($varname).
                  '='.rawurlencode($value));
         }
      }
      $link .= htmlspecialchars($this->cgi['persist']);
      $link .= '">'.$this->labels['Select fields'].'</a>';
      return $link;
   } /* }}} */

   function execute() /* {{{ */
   {
      //global $_GET;
      //global $_POST;

      /*
       * Extracting field names
       */

      $table_cols     = array();
      $all_table_cols = array();

      if ($this->connect() == false) {
         return false;
      }
      $query_parts = array(
            'type'   => 'select',
            'select' => '*',
            'from'   => $this->tb,
            'limit'  => $this->sql_limit('1'));
      $result = $this->myquery($this->get_SQL_query($query_parts), __LINE__);
      $all_table_cols = array_keys(@mysql_fetch_array($result, MYSQL_ASSOC));
      if (count($all_table_cols) <= 0) {
         $this->error('database fetch error');
         return false;
      }
      foreach (array_keys($this->fdd) as $field_name) {
         if (preg_match('/^\d*$/', $field_name))
            continue;
         if (($idx = array_search($field_name, $all_table_cols)) !== false)
            $table_cols[$field_name] = mysql_field_len($result, $idx);
      }
      @mysql_free_result($result);
      unset($all_table_cols);

      /*
       * Preparing variables
       */

      $fields_select  = $this->get_cgi_var('fields_select');
      $filter         = $this->get_cgi_var('filter');
      $prepare_filter = $this->get_cgi_var('prepare_filter');
      $this->inc      = intval($this->get_cgi_cookie_var('inc'));
      $force_select   = true;
      $none_displayed = true;
      $expire_time    = time() + (3600 * 24 * 30 * 12 * 5); // five years
      $headers_sent   = @headers_sent();

      foreach (array_merge(array('@inc'), array_keys($table_cols)) as $col) {
         $varname = ($col[0] == '@' ? substr($col, 1) : 'have_'.$col);
         if (isset($_POST[$varname]) || isset($_GET[$varname])) {
            $value = $_POST[$varname];
            if (isset($_GET[$varname])) {
               $value = $_GET[$varname];
            }
            if ($varname != 'inc' && ! empty($value)) {
               $force_select = false;
            }
            $headers_sent || setcookie($varname.'_'.$this->tb.'_cookie', $value, $expire_time);
            $this->cgi['persist'] .= '&'.urlencode($varname);
            $this->cgi['persist'] .= '='.urlencode($value);
         } else {
            $headers_sent || setcookie($varname.'_'.$this->tb.'_cookie', '', time() - 10000);
         }
      }

      $i = -1;
      foreach (array_keys($this->fdd) as $key) {
         $i++;
         if (preg_match('/^\d*$/', $key))
            continue;
         $varname = 'have_'.$key;
         $value   = @$this->get_cgi_cookie_var($varname, '');
         $options = @$value ? 'LV' : '';
         $this->fdd[$i]['options']   = $options;
         $this->fdd[$key]['options'] = $options;
         $this->displayed[$i] = @$value ? true : false;
         $value && $none_displayed = false;
      }

      /*
       * Redirecting when neccessary
       * (hackity hack with unregistering/unchecking fields)
       */

      if ($prepare_filter && ! $headers_sent) {
         $this->execute_redirect();
         exit;
      }

      /*
       * Check if field selection report screen has to be displayed
       */

      if (isset($fields_select) || $force_select || $none_displayed) {
         $this->execute_report_screen($table_cols);
         return true;
      }

      if (0) {
         $this->message .= $this->get_select_fields_link();
      }

      // parent class call
      return parent::execute();
   } /* }}} */

   function execute_redirect() /* {{{ */
   {
      //global $_SERVER;
      //global $_GET;
      //global $_POST;
      $redirect_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
      $delim = '?';
      foreach ($_POST + $_GET as $cgi_var_name => $cgi_var_value) {
         $cgi_var_name == 'prepare_filter' && $cgi_var_name = 'filter';
         $redirect_url .= $delim;
         $redirect_url .= rawurlencode($cgi_var_name).'='.rawurlencode($cgi_var_value);
         $delim == '?' && $delim = '&';
      }
      $redirect_url .= $this->cgi['persist'];
      header('Location: '.$redirect_url);
      exit;
   } /* }}} */

   function execute_report_screen($table_cols) /* {{{ */
   {
      echo '<form class="',$this->getCSSclass('form'),'" action="';
      echo htmlspecialchars($this->page_name),'" method="POST">',"\n";
      if ($this->nav_up()) {
         $this->display_report_selection_buttons('up');
         echo '<hr class="',$this->getCSSclass('hr', 'up'),'">',"\n";
      }
      echo '<table class="',$this->getCSSclass('main'),'" summary="',$this->tb,'">',"\n";

      $i = 0;
      foreach ($table_cols as $key => $val) {
         $css_postfix    = @$this->fdd[$key]['css']['postfix'];
         $css_class_name = $this->getCSSclass('input', null, true, $css_postfix);
         $varname        = 'have_'.$key;
         $value          = $this->get_cgi_cookie_var($varname);
         $checked        = @$value ? ' checked' : '';
         echo '<tr class="',$this->getCSSclass('row', null, 'next', $css_postfix),'">',"\n";
         echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'">';
         echo $this->fdd[$i]['name'],'</td>',"\n";
         echo '<td class="',$this->getCSSclass('check', null, true, $css_postfix),'">';
         echo '<input class="',$css_class_name,'" type="checkbox" name="';
         echo htmlspecialchars($varname),'"',$checked,'>';
         echo '</td>',"\n";
         echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'"';
         echo $this->getColAttributes($key),">\n";
         $varname = 'PME_sys_qf'.$i;
         $value   = $this->get_cgi_cookie_var($varname);
         if ($this->fdd[$key]['select'] == 'D' || $this->fdd[$key]['select'] == 'M') {
            $from_table = ! $this->col_has_values($key) || isset($this->fdd[$key]['values']['table']);
            $selected   = $value;
            $value      = $this->set_values($key, array('*' => '*'), null, $from_table);
            $multiple   = $this->col_has_multiple_select($key);
            $multiple  |= $this->fdd[$key]['select'] == 'M';
            $readonly   = false;
            $strip_tags = true;
            $escape     = true;
            echo $this->htmlSelect($varname.'_id', $css_class_name, $value, $selected,
                  $multiple, $readonly, $strip_tags, $escape);
         } else {
            echo '<input class="',$css_class_name,'" type=text name="';
            echo htmlspecialchars($varname),'" value="',htmlspecialchars($value),'" size="';
            echo min(40, $val),'" maxlength="',min(40, max(10, $val)),'">';
         }
         echo '</td>',"\n",'</tr>',"\n";
         $i++;
      }
      echo '<tr class="',$this->getCSSclass('row', null, 'next', $css_postfix),'">',"\n";
      echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'" colspan="2">';
      echo $this->labels['Records per screen'],'</td>';
      echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'">';
      echo '<input class="',$css_class_name,'" type="text" name="inc" value="',$this->inc.'">';
      echo '</td></tr>',"\n";
      echo '</table>',"\n";
      if ($this->nav_down()) {
         echo '<hr class="',$this->getCSSclass('hr', 'down'),'">',"\n";
         $this->display_report_selection_buttons('down');
      }
      echo '</form>';
   } /* }}} */

}

/* Modeline for ViM {{{
* vim:set ts=4:
* vim600:fdm=marker fdl=0 fdc=0:
* }}} */

?>


@ doug -> could you update the repo with this version, thanks

 
msavi     Joined: 26 Jan 2010   Posts: 10  
Post Posted: 2010-01-26 11:26
Back to top  Reply with quote     

Skipper wrote:
working PHP 5 code for phpMyEdit-report.class.php

Code:
<?php

/*
* phpMyEdit - instant MySQL table editor and code generator
*
* extensions/phpMyEdit-report.class.php - phpMyEdit report extension
* ____________________________________________________________
*
* Developed by Ondrej Jombik <nepto@platon.sk>
* Copyright (c) 2002-2006 Platon Group, http://platon.sk/
* All rights reserved.
*
* See README file for more information about this software.
* See COPYING file for license information.
*
* Download the latest version from
* http://platon.sk/projects/phpMyEdit/
*/

/* $Platon: phpMyEdit/extensions/phpMyEdit-report.class.php,v 1.13 2008-11-11 04:46:39 nepto Exp $ */

/* Extension TODO:

   - allow user to enable/disable particular field in reporting (maybe 'X' flag
     for indicating that field is forbidden is good idea)
   - support for ['help'] in select fields screen
   - make extension's option for selecting "Select fields" link or button
*/

require_once dirname(__FILE__).'/../phpMyEdit.class.php';

class phpMyEdit_report extends phpMyEdit
{

   function phpMyEdit_report($opts) /* {{{ */
   {
      $opts['options'] = 'L';
      $execute = 1;
      isset($opts['execute']) && $execute = $opts['execute'];
      $opts['execute'] = 0;
      parent::phpMyEdit($opts);
      $execute && $this->execute();
   } /* }}} */

   function make_language_labels($language) /* {{{ */
   {
      $ret = parent::make_language_labels($language);
      strlen($ret['Make report'])        <= 0 && $ret['Make report']        = 'Make report';
      strlen($ret['Select fields'])      <= 0 && $ret['Select fields']      = 'Select fields';
      strlen($ret['Records per screen']) <= 0 && $ret['Records per screen'] = 'Records per screen';
      return $ret;
   } /* }}} */

   function get_cgi_cookie_var($name, $default_value = null) /* {{{ */
   {
      $ret = $this->get_cgi_var($name, null);
      if ($ret === null) {
         global $HTTP_COOKIE_VARS;
         $ret = @$HTTP_COOKIE_VARS[$name.'_'.$this->tb.'_cookie'];
         if (! isset($ret)) {
            $ret = $default_value;
         }
      }
      return $ret;
   } /* }}} */

   function display_list_table_buttons($total_recs, $position) /* {{{ */
   {   /* This is mostly copy/paste from core class. */
      $listall = $this->inc <= 0; // Are we doing a listall?
      echo '<table class="',$this->getCSSclass('navigation', $position),'">',"\n";
      echo '<tr class="',$this->getCSSclass('navigation', $position),'">',"\n";
      echo '<td class="',$this->getCSSclass('buttons', $position),'">',"\n";
      echo '<input class="',$this->getCSSclass('fields-select', $position);
      echo '" type="submit" name="fields_select" value="',$this->labels['Select fields'],'">&nbsp;';
      // Note that <input disabled isn't valid HTML, but most browsers support it
      $disabled = ($this->fm > 0 && ! $listall) ? '' : ' disabled';
      echo '<input',$disabled,' class="',$this->getCSSclass('prev', $position);
      echo '" type="submit" name="',ltrim($disabled),'prev" value="',$this->labels['Prev'],'">&nbsp;';
      $disabled = ($this->fm + $this->inc < $total_recs && ! $listall) ? '' : ' disabled';
      echo '<input',$disabled,' class="',$this->getCSSclass('next', $position);
      echo '" type="submit" name="',ltrim($disabled),'next" value="',$this->labels['Next'],'">';
      // Message is now written here
      echo '</td>',"\n";
      if (strlen(@$this->message) > 0) {
         echo '<td class="',$this->getCSSclass('message', $position),'">',$this->message,'</td>',"\n";
      }
      // Display page and records statistics
      echo '<td class="',$this->getCSSclass('stats', $position),'">',"\n";
      if ($listall) {
         echo $this->labels['Page'],':&nbsp;1&nbsp;',$this->labels['of'],'&nbsp;1';
      } else {
         echo $this->labels['Page'],':&nbsp;',($this->fm / $this->inc) + 1;
         echo '&nbsp;',$this->labels['of'],'&nbsp;',max(1, ceil($total_recs / abs($this->inc)));
      }
      echo '&nbsp; ',$this->labels['Records'],':&nbsp;',$total_recs;
      echo '</td></tr></table>',"\n";
   } /* }}} */

   function display_report_selection_buttons($position) /* {{{ */
   {
      echo '<table class="',$this->getCSSclass('navigation', $position),'">',"\n";
      echo '<tr class="',$this->getCSSclass('navigation', $position),'">',"\n";
      echo '<td class="',$this->getCSSclass('buttons', $position),'">',"\n";
      echo '<input class="',$this->getCSSclass('make-report', $position);
      echo '" type="submit" name="prepare_filter" value="',$this->labels['Make report'],'">',"\n";
      echo '</td></tr></table>',"\n";
   } /* }}} */

   function get_select_fields_link() /* {{{ */
   {
      $link = '<a href="'.htmlspecialchars($this->page_name).'?fields_select=1';
      for ($i = 0; $i < count($table_cols); $i++) {
         $varname = 'qf'.$i;
         $value   = $this->get_cgi_cookie_var($varname);
         if (! empty($value)) {
            $link .= htmlspecialchars(
                  '&'.rawurlencode($varname).
                  '='.rawurlencode($value));
         }
      }
      $link .= htmlspecialchars($this->cgi['persist']);
      $link .= '">'.$this->labels['Select fields'].'</a>';
      return $link;
   } /* }}} */

   function execute() /* {{{ */
   {
      //global $_GET;
      //global $_POST;

      /*
       * Extracting field names
       */

      $table_cols     = array();
      $all_table_cols = array();

      if ($this->connect() == false) {
         return false;
      }
      $query_parts = array(
            'type'   => 'select',
            'select' => '*',
            'from'   => $this->tb,
            'limit'  => $this->sql_limit('1'));
      $result = $this->myquery($this->get_SQL_query($query_parts), __LINE__);
      $all_table_cols = array_keys(@mysql_fetch_array($result, MYSQL_ASSOC));
      if (count($all_table_cols) <= 0) {
         $this->error('database fetch error');
         return false;
      }
      foreach (array_keys($this->fdd) as $field_name) {
         if (preg_match('/^\d*$/', $field_name))
            continue;
         if (($idx = array_search($field_name, $all_table_cols)) !== false)
            $table_cols[$field_name] = mysql_field_len($result, $idx);
      }
      @mysql_free_result($result);
      unset($all_table_cols);

      /*
       * Preparing variables
       */

      $fields_select  = $this->get_cgi_var('fields_select');
      $filter         = $this->get_cgi_var('filter');
      $prepare_filter = $this->get_cgi_var('prepare_filter');
      $this->inc      = intval($this->get_cgi_cookie_var('inc'));
      $force_select   = true;
      $none_displayed = true;
      $expire_time    = time() + (3600 * 24 * 30 * 12 * 5); // five years
      $headers_sent   = @headers_sent();

      foreach (array_merge(array('@inc'), array_keys($table_cols)) as $col) {
         $varname = ($col[0] == '@' ? substr($col, 1) : 'have_'.$col);
         if (isset($_POST[$varname]) || isset($_GET[$varname])) {
            $value = $_POST[$varname];
            if (isset($_GET[$varname])) {
               $value = $_GET[$varname];
            }
            if ($varname != 'inc' && ! empty($value)) {
               $force_select = false;
            }
            $headers_sent || setcookie($varname.'_'.$this->tb.'_cookie', $value, $expire_time);
            $this->cgi['persist'] .= '&'.urlencode($varname);
            $this->cgi['persist'] .= '='.urlencode($value);
         } else {
            $headers_sent || setcookie($varname.'_'.$this->tb.'_cookie', '', time() - 10000);
         }
      }

      $i = -1;
      foreach (array_keys($this->fdd) as $key) {
         $i++;
         if (preg_match('/^\d*$/', $key))
            continue;
         $varname = 'have_'.$key;
         $value   = @$this->get_cgi_cookie_var($varname, '');
         $options = @$value ? 'LV' : '';
         $this->fdd[$i]['options']   = $options;
         $this->fdd[$key]['options'] = $options;
         $this->displayed[$i] = @$value ? true : false;
         $value && $none_displayed = false;
      }

      /*
       * Redirecting when neccessary
       * (hackity hack with unregistering/unchecking fields)
       */

      if ($prepare_filter && ! $headers_sent) {
         $this->execute_redirect();
         exit;
      }

      /*
       * Check if field selection report screen has to be displayed
       */

      if (isset($fields_select) || $force_select || $none_displayed) {
         $this->execute_report_screen($table_cols);
         return true;
      }

      if (0) {
         $this->message .= $this->get_select_fields_link();
      }

      // parent class call
      return parent::execute();
   } /* }}} */

   function execute_redirect() /* {{{ */
   {
      //global $_SERVER;
      //global $_GET;
      //global $_POST;
      $redirect_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
      $delim = '?';
      foreach ($_POST + $_GET as $cgi_var_name => $cgi_var_value) {
         $cgi_var_name == 'prepare_filter' && $cgi_var_name = 'filter';
         $redirect_url .= $delim;
         $redirect_url .= rawurlencode($cgi_var_name).'='.rawurlencode($cgi_var_value);
         $delim == '?' && $delim = '&';
      }
      $redirect_url .= $this->cgi['persist'];
      header('Location: '.$redirect_url);
      exit;
   } /* }}} */

   function execute_report_screen($table_cols) /* {{{ */
   {
      echo '<form class="',$this->getCSSclass('form'),'" action="';
      echo htmlspecialchars($this->page_name),'" method="POST">',"\n";
      if ($this->nav_up()) {
         $this->display_report_selection_buttons('up');
         echo '<hr class="',$this->getCSSclass('hr', 'up'),'">',"\n";
      }
      echo '<table class="',$this->getCSSclass('main'),'" summary="',$this->tb,'">',"\n";

      $i = 0;
      foreach ($table_cols as $key => $val) {
         $css_postfix    = @$this->fdd[$key]['css']['postfix'];
         $css_class_name = $this->getCSSclass('input', null, true, $css_postfix);
         $varname        = 'have_'.$key;
         $value          = $this->get_cgi_cookie_var($varname);
         $checked        = @$value ? ' checked' : '';
         echo '<tr class="',$this->getCSSclass('row', null, 'next', $css_postfix),'">',"\n";
         echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'">';
         echo $this->fdd[$i]['name'],'</td>',"\n";
         echo '<td class="',$this->getCSSclass('check', null, true, $css_postfix),'">';
         echo '<input class="',$css_class_name,'" type="checkbox" name="';
         echo htmlspecialchars($varname),'"',$checked,'>';
         echo '</td>',"\n";
         echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'"';
         echo $this->getColAttributes($key),">\n";
         $varname = 'PME_sys_qf'.$i;
         $value   = $this->get_cgi_cookie_var($varname);
         if ($this->fdd[$key]['select'] == 'D' || $this->fdd[$key]['select'] == 'M') {
            $from_table = ! $this->col_has_values($key) || isset($this->fdd[$key]['values']['table']);
            $selected   = $value;
            $value      = $this->set_values($key, array('*' => '*'), null, $from_table);
            $multiple   = $this->col_has_multiple_select($key);
            $multiple  |= $this->fdd[$key]['select'] == 'M';
            $readonly   = false;
            $strip_tags = true;
            $escape     = true;
            echo $this->htmlSelect($varname.'_id', $css_class_name, $value, $selected,
                  $multiple, $readonly, $strip_tags, $escape);
         } else {
            echo '<input class="',$css_class_name,'" type=text name="';
            echo htmlspecialchars($varname),'" value="',htmlspecialchars($value),'" size="';
            echo min(40, $val),'" maxlength="',min(40, max(10, $val)),'">';
         }
         echo '</td>',"\n",'</tr>',"\n";
         $i++;
      }
      echo '<tr class="',$this->getCSSclass('row', null, 'next', $css_postfix),'">',"\n";
      echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'" colspan="2">';
      echo $this->labels['Records per screen'],'</td>';
      echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'">';
      echo '<input class="',$css_class_name,'" type="text" name="inc" value="',$this->inc.'">';
      echo '</td></tr>',"\n";
      echo '</table>',"\n";
      if ($this->nav_down()) {
         echo '<hr class="',$this->getCSSclass('hr', 'down'),'">',"\n";
         $this->display_report_selection_buttons('down');
      }
      echo '</form>';
   } /* }}} */

}

/* Modeline for ViM {{{
* vim:set ts=4:
* vim600:fdm=marker fdl=0 fdc=0:
* }}} */

?>


@ doug -> could you update the repo with this version, thanks


this does not work for me. still get errors such as
phpMyEdit error: database fetch error
can anybody help?

 
Skipper     Joined: 20 Aug 2009   Posts: 7  
Post Posted: 2010-01-26 15:10
Back to top  Reply with quote     

Pls. check your provided error messages - the fields and thier data dependencies, additional the choosen fields in the form .

Don't forget to set 'Records per screen' at the end of the form.

Here the Addon works - but if someone changes the data base sructure it can happen the once created report fails and then needs some rework.

Can you post the error messages you got?

 
msavi     Joined: 26 Jan 2010   Posts: 10  
Post Posted: 2010-01-26 15:46
Back to top  Reply with quote     

phone listing

Warning: Missing argument 2 for phpMyEdit::sql_limit(), called in /hermes/web10/b2779/moo.msavi/purim/admin/phpmyedit/extensions/phpMyEdit-report.class.php on line 145 and defined in /hermes/web10/b2779/moo.msavi/purim/admin/phpmyedit/phpMyEdit.class.php on line 356
MySQL error 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Warning: array_keys() [function.array-keys]: The first argument should be an array in /hermes/web10/b2779/moo.msavi/purim/admin/phpmyedit/extensions/phpMyEdit-report.class.php on line 147
phpMyEdit error: database fetch error

 
Skipper     Joined: 20 Aug 2009   Posts: 7  
Post Posted: 2010-01-26 16:19
Back to top  Reply with quote     

Looks like the query tries to fetch a required (madatory) field but got NULL as result.

If need further help and its not too big can you post the table sql and the report config file?

 
twhit67     Joined: 03 Feb 2010   Posts: 16  
Post Posted: 2010-02-03 21:25
Back to top  Reply with quote     

Getting MySQL error 1604
PHP Warning: array_keys(): The first argument should be an array in ..\extensions\phpMyEdit-report.class.php on line 147

line 147:
$all_table_cols = array_keys(@mysql_fetch_array($result, MYSQL_ASSOC));
if (count($all_table_cols) <= 0) {
$this->error('database fetch error');
return false;
}
foreach (array_keys($this->fdd) as $field_name) {
if (preg_match('/^\d*$/', $field_name))
continue;
if (($idx = array_search($field_name, $all_table_cols)) !== false)
$table_cols[$field_name] = mysql_field_len($result, $idx);
}
@mysql_free_result($result);
unset($all_table_cols);

/*
* Preparing variables
*/

I'm using syntax of new Report Class submitted here on forum.

 
Skipper     Joined: 20 Aug 2009   Posts: 7  
Post Posted: 2010-02-04 07:49
Back to top  Reply with quote     

I compared my report and my table config file once again and I guess I had to change the 'select' type to 'D' for dropdowns (table lookups) to get it work properly

'select' => 'D',

e.g.

Code:

//...

// Options you wish to give the users
// A - add,  C - change, P - copy, V - view, D - delete,
// F - filter, I - initial sort suppressed
$opts['options'] = 'ACVDF';

//...

$opts['fdd']['branch_id'] = array(
  'name'     => 'Branch',
  'select'   => 'D',
  'options'    => 'ACPV',
  'maxlen'   => 4,
  'values' => array(
    'table'  => 'tbl_branch',
    'column' => 'id'
  ),

  'sort'     => true
);
$opts['fdd']['branch_id']['values']['description']['columns'][0] = 'branch';
// Separator suppresses description for values2
$opts['fdd']['branch_id']['values']['description']['divs'][0]    = ' ';
//Dropdown element "No entry" passes NULL to table
$opts['fdd']['branch_id']['values2'] = array("" => 'No entry');
$opts['fdd']['branch_id']['sqlw'] = 'IF($val_qas = "", NULL, $val_qas)';

//...

// Now important call to phpMyEdit
require_once 'phpMyEdit.class.php';
// Now important call to phpMyEdit
require_once 'extensions/phpMyEdit-report.class.php';
new phpMyEdit_report($opts);



Did you set 'select' => 'D', for table look ups?

 
twhit67     Joined: 03 Feb 2010   Posts: 16  
Post Posted: 2010-02-04 17:37
Back to top  Reply with quote     

Did a change to select 'D' with no change to errors.

Further review of errors reflect:

[04-Feb-2010 11:28:08] PHP Warning: Missing argument 2 for phpMyEdit::sql_limit(), called in ..\extensions\ phpMyEdit-report.class.php on line 145 and defined in ..\ phpMyEdit.class.php on line 356

[04-Feb-2010 11:28:08] PHP Warning: array_keys(): The first argument should be an array in ..extensions\ phpMyEdit-report.class.php on line 147
-------------------------------------------------
Line 145-147:
'limit' => $this->sql_limit('1'));
$result = $this->myquery($this->get_SQL_query($query_parts), __LINE__);
$all_table_cols = array_keys(@mysql_fetch_array($result, MYSQL_ASSOC));
if (count($all_table_cols) <= 0) {
$this->error('database fetch error');
return false;
}

Line 356 from phpMyEdit.class.php
function sql_limit($start, $more) /* {{{ */
{
return ' LIMIT '.$start.', '.$more.' ';
} /* }}} */

 
Post new topic   Reply to topic   Goto page 1, 2  Next  

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy