[thelist] tips

Jay Greenspan jay at trans-city.com
Mon Jan 15 12:22:38 CST 2001


two off-topic emails, two tips...

<tip type="PHP">
On my development server at home (linux/apache/php/mysql) my file
organization was not so great. To keep track of my files I wrote this
funciton which lists all the files under the root directory, along with a
link to the file


function recurse_directory($path="")
{
     global $DOCUMENT_ROOT, $HTTP_HOST
     if (empty($path)) {$path = $DOCUMENT_ROOT;}
     if(!is_dir($path))
     {
          return FALSE;
     }

     $dir = opendir($path);
     echo "<ul>";
     while ($file = readdir($dir))
     {
          if ($file != "." && $file != "..")
          {
               if (is_dir($path . "/" .$file))
               {
                    echo "<li><b>$file</b></li>";
                    recurse_directory($path . "/" . $file, $base_url,
$path);
               }
               else
               {
                    $url = "http://$HTTP_HOST/$path/$file";
                    $url = str_replace("$DOCUMENT_ROOT", "", $url);
                    echo "<li> <a href = \"$url\">$file</a></li>";

               }
          }
     }
     echo "</ul>";
}
recurse_directory();
?>

</tip>


<tip type="mysql">
Before selecting MySQL for your applictions, it really pays to look at the
exact scope of what you're doing. Much has been made of the lack of
transaction support (which is now remedied, sort of), but I found that
missing sub-selects can really be a problem. Yes, you can use straight joins
and outer joins to make up for the lack of sub-selects for simpler
behaviors. But, in the event you need to, say, join on resutls of an
aggregate function (like max()), the queries get difficult to write and
read. 

</tip>






More information about the thelist mailing list