Location: PHPKode > projects > AJAX MySQL Admin > ajaxmysqladmin/www/api/generate.php
<?php
    require_once ('inc/constants.inc');
    require_once ('inc/generic_start.inc');

    $query = "SHOW TABLES FROM $dbname";
    $conn = mysql_connect ($dbhost . ":" . $dbport, $dbuser, $dbpass);
    $result = mysql_query ($query, $conn);
    if ($result !== FALSE && mysql_num_rows ($result) > 0) {
        $count = 0;
        while ($row = mysql_fetch_row($result)) {
            if ($count > 0) echo "," . NL;
            echo "'" . $row[0] . "'";
            $count ++;
        }
        mysql_free_result ($result);
        ?>
        {response:1,url:
        <?php
    } else {
        ?>
        {response:0,mysqlerror:<?php echo mysql_error (); ?>}
        <?php
    }
    $shown = true;
    mysql_close ($conn);
?>
{
}
<?php
    require_once ('inc/generic_finish.inc');

    function makeClass () {
        String props = "";
        String methods = "";
        String imports = "import org.apache.commons.logging.Log;\n"
                        + "import org.apache.commons.logging.LogFactory;\n";

        String toStringStr = "";

        for (int i = 0; i < properties.size (); i ++) {
            Property prop = (Property) properties.get (i);

            props += "\t" + prop.getValue () + " " + prop.getKey () + ";\n";

            String name = prop.getKey ();
            if (name != null) {
                name = name.substring (0, 1).toUpperCase () + name.substring (1);
            }

            if (!"".equals (methods)) {
                methods += "\n\n";
            }

            methods += "\tpublic void set" + name + " (" + prop.getValue () + " value) {\n";
            methods += "\t\tthis." + prop.getKey () + " = value;\n";
            methods += "\t}\n";

            methods += "\tpublic " + prop.getValue () + " get" + name + " () {\n";
            methods += "\t\treturn this." + prop.getKey () + ";\n";
            methods += "\t}";

            if (!"".equals (toStringStr)) toStringStr += "\n\t\t\t+ ";

            if ("Calendar".equals (prop.getValue ())) {
                imports += "import java.util.Calendar;\n"
                            + "import com.twofourhour.time.DateFormat;\n";
                toStringStr += "\"" + prop.getKey () + "=\" + DateFormat.serialString (get" + name + "(), \"d/m/Y\")";
            } else
                toStringStr += "\"" + prop.getKey () + "=\" + get" + name + "()";
        }

        if (!"".equals (toStringStr)) {
            methods += "\n\n\tpublic String toString () {\n";
            methods += "\t\treturn " + toStringStr + ";\n";
            methods += "\t}\n";
        }

        code = "package "
            + packageName + ";\n"
            + "\n\n"
            + imports + "\n"
            + "\n\n"
            + "public class " + className + " {\n"
                + "\n\n"
                + "\tprotected final Log logger = LogFactory.getLog (getClass ().getName ());\n"
                + "\t// final Log logger = LogFactory.getLog (\"" + packageName + "." + className + "\");\n"
                + "\n\n"
                + props + "\n"
                + "\n\n"
                + methods + "\n"
                + "\n\n"
            + "}\n";
    }
?>
Return current item: AJAX MySQL Admin