Re: PHP4 vs PHP5 classes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>
> Since the Players method is a constructor, it's more about how you set
> the object(s) up.
>
> What does the loop look like before you create a new object?
>

Well see here is where it gets messy! This is not my code - I've ported a
phpnuke module over to dragonflycms.

The $players object is created before the loop:
$players = new Players($lid);

The loop is quite big, but here is the important part:

-------------SNIP-------------
while (list($pid, $name, $gsid, $stat) = $players->fetchSelectData()) {
      if (DEBUG_LEAGUE == "YES") echo "<tr><td colspan=\"22\">\$maxcol =
$maxcol | \$pid = $pid | \$name = $name | \$gsid = $gsid | \$stat =
$stat</td></tr>\$
      $noplayer=0;
      if ($prevgsid != $gsid) {
         $prevgsid = $gsid;
         $players->selectHeaders($gsid);
         if (DEBUG_LEAGUE == "YES") var_dump($players);
         displayPlayerSetupRow($players,
"".getlink("$module")."&amp;&file=index&amp;mode=$mode&amp;lid=$lid&amp;sid=$sid&amp;gsid=$gsid",
$order);
      }
-------------SNIP-------------

function displayPlayerSetupRow is also very big, but here it is up to the
troublesome $players->max call:

-------------SNIP-------------
function displayPlayerSetupRow($players, $go="", $prevorder=0) {
   global $bgcolor2;

   if ($prevorder=="")
      $prevorder=0;

   $urlstart="";
   $urlend="";
   $max = $players->max();

-------------SNIP-------------

Then we enter class Players as previously mentioned:

-------------SNIP-------------
class Players extends dynamicTable {
   var $setup;
   var $lid;
   var $size;
   var $max;
   var $data;
   var $data_result;
   var $data_index;
   var $player_stats_result;
   var $player_stats_data;
   var $player_stats_index;
   var $player_stats_start;
   var $player_type_result;

   function Players($lid) {
      global $prefix, $db;

      /*
       * Find max size of rows
       */

      $this->lid = $lid;
      $this->max=0;
      $result = $db->sql_query("select * from " . $prefix .
"_league_games_setup where lid = $lid");
      while (($rows = $db->sql_fetchrow($result))) {
         $c=0;
         for ($i=3; $i < 23; $i++) {
          if ($rows[$i] != "")
             $c++;
         }
         if ($c > $this->max)
            $this->max = $c;
      }

      $this->index = 3;
   }

   function name() {
      return ($this->setup['name']);
   }

   function max() {
        return ($this->max);
   }
-------------SNIP-------------






> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
> --
> This email has been scanned for viruses and dangerous content by
> Sydney Technology Solutions MailMaster Email Protection Services.
>
> For more information please visit http://www.sydneytech.com.au
> :Scanned by MailMaster1:
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux