PHP Classes

File: step4.php

Recommend this page to a friend!
  Classes of dan boorn   OO Mysql Wrapper   step4.php   Download  
File: step4.php
Role: Application script
Content type: text/plain
Description: Script to generate example PHP Code
Class: OO Mysql Wrapper
MySQL database SQL queries wrapper
Author: By
Last change: Updated Output Errors.
Date: 17 years ago
Size: 4,580 bytes
 

Contents

Class file image Download
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Code Generator</title>
</head>
<body>
<p align="center"><strong>OO Mysql Wrapper PHP Coder Generator</strong></p>
<script src="validate.js" type="text/javascript"></script>

  <div align="center"><a href="index.htm">Start Again</a></div>
  <table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td><strong>Generated Code</strong></td>
      <td>&nbsp;</td>
    </tr>
    <?
        $post
= $_POST;
       
       
$code .= "<?php \n\n";
       
$code .= "require('mysql.php');\n";
       
$code .= '$mysql = new mysql();'."\n\n";
       
$code .= '$node = new sqlNode();'."\n";
       
$code .= '$node->table = "'.$post['Table'].'";'."\n\n";
        switch(
$post['type']){
            case
"Insert Row":
               
$num_of_fields = count($post['fieldType']);
                for(
$i = 0; $i < $num_of_fields; $i++){
                   
$code .= '$node->push("'.$post['fieldType'][$i].'","'.$post['fieldName'][$i].'",';
                    switch(
$post["valueType"][$i]){
                        case
"Post":
                           
$code .= '$_POST["'.$post['fieldValue'][$i].'"]);'."\n";
                            break;
                        case
"Get":
                           
$code .= '$_GET["'.$post['fieldValue'][$i].'"]);'."\n";
                            break;
                        case
"Session":
                           
$code .= '$_SESSION["'.$post['fieldValue'][$i].'"]);'."\n";
                            break;
                        default:
                           
$code .= "\"".$post['fieldValue'][$i]."\");\n";
                            break;
                    }
                }
               
$code .= "\n\n".'if(($result = $mysql->insert($node)) === false)'."\n";
               
$code .= ' die($mysql->debugPrint());'."\n\n";
                break;
            case
"Edit Row":
               
$num_of_fields = count($post['fieldType']);
                for(
$i = 0; $i < $num_of_fields; $i++){
                   
$code .= '$node->push("'.$post['fieldType'][$i].'","'.$post['fieldName'][$i].'",';
                    switch(
$post["valueType"][$i]){
                        case
"Post":
                           
$code .= '$_POST["'.$post['fieldValue'][$i].'"]);'."\n";
                            break;
                        case
"Get":
                           
$code .= '$_GET["'.$post['fieldValue'][$i].'"]);'."\n";
                            break;
                        case
"Session":
                           
$code .= '$_SESSION["'.$post['fieldValue'][$i].'"]);'."\n";
                            break;
                        default:
                           
$code .= "\"".$post['fieldValue'][$i]."\");\n";
                            break;
                    }
                }
               
$code .= '$node->where = "'.$post['Where'].'"'.";\n";
               
$code .= "\n\n".'if(($result = $mysql->update($node)) === false)'."\n";
               
$code .= ' die($mysql->debugPrint());'."\n\n";
                break;
            case
"Delete Row":
               
$code .= '$node->where = "'.$post['Where'].'"'.";\n";
               
$code .= "\n\n".'if(($result = $mysql->delete($node)) === false)'."\n";
               
$code .= ' die($mysql->debugPrint());'."\n\n";
                break;
            case
"Select":
               
$code .= '$node->select = "'.$post['Select'].'";'."\n";
                if(
$post['Where'] != "")
                   
$code .= '$node->where = "'.$post['Where'].'"'.";\n";
                if(
$post['Orderby'] != "")
                   
$code .= '$node->orderby = "'.$post['Orderby'].'";'."\n";
               
$code .= "\n\n".'if(($result = $mysql->select($node)) === false)'."\n";
               
$code .= ' die($mysql->debugPrint());'."\n\n";
                break;
                               
        }
       
       
$code .= "\n\n?>\n";
       
        if(
$post['genForm'] == "Yes"){
           
$form .= "\n\n\n";
           
$form .= '<form action="<?=$_SERVER["PHP_SELF"];?>" method="'.$post['method'].'">'."\n";
           
$form .= "<table cellpadding=2>\n";
           
$num_of_fields = count($post['fieldType']);
            for(
$i = 0; $i < $num_of_fields; $i++){
               
$form .= " <tr>\n";
               
$form .= " <td>".$post['fieldName'][$i]."</td>\n";
               
$form .= " <td><input type=text name='".$post['fieldName'][$i]."' value='".$post['fieldValue'][$i]."'></td>\n";
               
$form .= " </tr>\n";
            }
           
$form .= " <tr>\n";
           
$form .= " <td></td>\n";
           
$form .= " <td><input type=submit value='Submit'></td>\n";
           
$form .= " </tr>\n";
           
$form .= "</table>\n</form>\n";
        }

        echo
"<tr>";
          echo
"<td colspan=2><textarea style='width:100%; height: 400px'>$code</textarea>";
        echo
"</tr>";
        echo
"<tr>";
          echo
"<td><strong>Generated Form</strong></td><td></td>";
        echo
"</tr>";
        echo
"<tr>";
          echo
"<td colspan=2><textarea style='width:100%; height: 400px'>$form</textarea>";
          echo
"Please note that only a basic HTML form code is generated. You may need to add additional input/code.</td>";
        echo
"</tr>";
   
?>

  </table>
  <div align="center"><a href="index.htm">Start Again</a></div>

<p>&nbsp;</p>
</body>

</html>