function getAllTables()
{
    $pdo = DbUtil::connect();
    $sql = "select table_name from information_schema.tables where table_schema='numeracy'";
    //$sql ="DESCRIBE   numeracy.m01_user";
    $values = $pdo->query($sql);
    $count = 1;
    $result = "";
    $tableArray = array();
    if (is_array($values) || is_object($values)) {
        foreach ($values as $row) {
            $tableName = $row['table_name'];
            print "<p class='btn-info'>" . $count++ . " >" . dashesToCamelCase($tableName, true) . "Controller.php</p><br/>";
            print "<div class='alert alert-danger clearfix'> &lt;?php<br/>";
            //	print('<br/>namespace com\numeracy\BO; <br/>');
            //print('	require __DIR__ . "\BaseBO.php"; <br/>use com\numeracy\BO\BaseBO; <br/> ' );
            //print("class ".dashesToCamelCase($tableName,true)."BO extends BaseBO {<br/>");
            //print("class ".dashesToCamelCase($tableName,true)."Controller  {<br/>");
            $tableArray[] = $row['table_name'];
            getControllerContents($tableName);
            //getAllColumns($tableName);
            //print("}<br/>");
            print "?&gt;<br/></div>";
            print "<br/>";
        }
    }
    DbUtil::disconnect();
    return $tableArray;
}
Example #2
0
 public function getAll()
 {
     $pdo = DbUtil::connect();
     $dao = new M04ChapterDao($pdo);
     $objArray = $dao->getAll();
     DbUtil::disconnect();
     return CommonUtil::objArrayToJson($objArray);
 }
Example #3
0
function getAllTables()
{
    $pdo = DbUtil::connect();
    $sql = "select table_name from information_schema.tables where table_schema='numeracy'";
    //$sql ="DESCRIBE   numeracy.m01_user";
    $values = $pdo->query($sql);
    $count = 1;
    $result = "";
    $tableArray = array();
    if (is_array($values) || is_object($values)) {
        foreach ($values as $row) {
            $tableName = $row['table_name'];
            print "<p class='btn-info'>" . $count++ . " >" . dashesToCamelCase($tableName, true) . "Facade.php</p><br/>";
            print "<div class='alert alert-danger clearfix'> &lt;?php<br/>";
            print 'namespace com\\numeracy\\facade; <br/>';
            print "&nbsp;&nbsp;&nbsp;    include_once '../util/DbUtil.php';<br/>\n\t\t\t\t\t\t\t&nbsp;&nbsp;&nbsp;    include_once '../util/CommonUtil.php';<br/>";
            print "&nbsp;&nbsp;&nbsp;    //bo includes<br/>\n\t\t\t\t\t\t\t&nbsp;&nbsp;&nbsp;    include_once '../bo/" . dashesToCamelCase($tableName, true) . "BO.php';<br/>\n\t\t\t\t\t\t\t<br/>\n\t\t\t\t\t\t\t&nbsp;&nbsp;&nbsp;    // dao includes<br/>\n\t\t\t\t\t\t\t&nbsp;&nbsp;&nbsp;    include_once '../dao/" . dashesToCamelCase($tableName, true) . "Dao.php';<br/>\n\t\t\t\t\t\t\t<br/>\n\t\t\t\t\t\t\t&nbsp;&nbsp;&nbsp;    // Util<br/>\n\t\t\t\t\t\t\t&nbsp;&nbsp;&nbsp;    use com\\numeracy\\util\\DbUtil;<br/>\n\t\t\t\t\t\t\t&nbsp;&nbsp;&nbsp;    use com\\numeracy\\util\\CommonUtil;<br/>\n\t\t\t\t\t\t\t<br/>\n\t\t\t\t\t\t\t&nbsp;&nbsp;&nbsp;    use com\\numeracy\\BO\\" . dashesToCamelCase($tableName, true) . "BO;<br/>\n\t\t\t\t\t\t\t&nbsp;&nbsp;&nbsp;    use com\\numeracy\\Dao\\" . dashesToCamelCase($tableName, true) . "Dao;<br/>";
            //print('	require __DIR__ . "\BaseBO.php"; <br/>use com\numeracy\BO\BaseBO; <br/> ' );
            //print("class ".dashesToCamelCase($tableName,true)."BO extends BaseBO {<br/>");
            print "class " . dashesToCamelCase($tableName, true) . "Facade  {<br/>";
            $tableArray[] = $row['table_name'];
            print "<br/>";
            getCreateFunction($tableName);
            print "<br/>";
            getUpdateFunction($tableName);
            print "<br/>";
            getDeleteFunction($tableName);
            print "<br/>";
            getAllFunction($tableName);
            print "}<br/>";
            print "?&gt;<br/></div>";
            print "<br/>";
        }
    }
    DbUtil::disconnect();
    return $tableArray;
}
Example #4
0
         foreach ($values as $row) {
             $tableName = $row['USERNAME'];
         }
     }
     if ($tableName == $username) {
         $_SESSION['login_user'] = $username;
         // Initializing Session
         header("location: ../view/index.php");
         // Redirecting To Other Page
     } else {
         $error = "Username or Password is invalid";
     }
 } else {
     $error = "Username or Password is invalid";
 }
 DbUtil::disconnect();
 /* 
 //$error = "Username or Password is invalid".$password.$password;
 // Establishing Connection with Server by passing server_name, user_id and password as a parameter
 $connection = mysql_connect("localhost", "vijay", "Zaq12wsx");
 // To protect MySQL injection for Security purpose
 
 // Selecting Database
 $db = mysql_select_db("company", $connection);
 // SQL query to fetch information of registerd users and finds user match.
 $query = mysql_query(, $connection); */
 /* $rows = mysql_num_rows($query);
 if ($rows == 1) {
 $_SESSION['login_user']=$username; // Initializing Session
 header("location: ../view/index.php"); // Redirecting To Other Page
 } else {
Example #5
0
/**
 * 
 * @param unknown $tableName
 */
function getAllColumns($tableName)
{
    $pdo = DbUtil::connect();
    $sql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'numeracy' AND TABLE_NAME = '" . $tableName . "'";
    //$sql ="DESCRIBE   numeracy.m01_user";
    $values = $pdo->query($sql);
    $count = 1;
    $result = "";
    $colnameArray = array();
    if (is_array($values) || is_object($values)) {
        foreach ($values as $row) {
            $colnameArray[] = $row['COLUMN_NAME'];
        }
    }
    $tableName = strtoupper($tableName);
    $idField = findIdField($tableName, $colnameArray);
    print '<br/>';
    print 'private static $insertSQL = "INSERT INTO ' . $tableName . ' (' . getInsert1($tableName, $colnameArray) . ')  VALUES (' . getInsert2($tableName, $colnameArray) . ')";</br>';
    print '<br/>';
    if ($idField != '') {
        print 'private static $selectSQL = "SELECT ' . getSelect($colnameArray) . ' FROM ' . $tableName . ' ORDER BY ' . $idField . ' DESC "; </br>';
    } else {
        print 'private static $selectSQL = "SELECT ' . getSelect($colnameArray) . ' FROM ' . $tableName . ' "; </br>';
    }
    print '<br/>';
    if ($idField != '') {
        print 'private static $updateSQL = "UPDATE ' . $tableName . ' SET ' . getUpdate($tableName, $colnameArray) . ' WHERE ' . $idField . ' = ? ";</br>';
    } else {
        //('private static $updateSQL = "UPDATE '.$tableName.' SET '.getUpdate($tableName, $colnameArray).' ";</br>');
        print 'private static $updateSQL = "UPDATE ' . $tableName . ' SET ' . getUpdate($tableName, $colnameArray) . ' WHERE CONDITIONFIELD = ? ";</br>';
    }
    print '<br/>';
    print 'private static $deleteSQL = "DELETE FROM ' . $tableName . ' WHERE ' . $idField . ' = ? ";</br>';
    print '<br/>';
    print 'private static $selectByIdSQL = "SELECT * FROM ' . $tableName . ' WHERE ' . $idField . ' = ? ";</br>';
    printCreateFunction($tableName, $colnameArray);
    printGetAllFunction($tableName, $colnameArray);
    printUpdateFunction($tableName, $colnameArray);
    printDeleteFunction($tableName, $colnameArray);
    printGetByIdFunction($tableName, $colnameArray, $idField);
    DbUtil::disconnect();
    //return $$colnameArray;
}
Example #6
0
function getAllColumns($tableName)
{
    $pdo = DbUtil::connect();
    $sql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'numeracy' AND TABLE_NAME = '" . $tableName . "'";
    //$sql ="DESCRIBE   numeracy.m01_user";
    $values = $pdo->query($sql);
    $count = 1;
    $result = "";
    $colnameArray = array();
    if (is_array($values) || is_object($values)) {
        foreach ($values as $row) {
            $colnameArray[] = $row['COLUMN_NAME'];
            print "&nbsp;&nbsp;&nbsp;    private \$" . dashesToCamelCase($row['COLUMN_NAME'], false) . ";<br/>";
            //print("&nbsp;&nbsp;&nbsp; COl".$count++ ." > ".dashesToCamelCase($row['COLUMN_NAME'],false)."<br/>");
        }
        foreach ($colnameArray as $colname) {
            $getFn = 'public function get' . dashesToCamelCase($colname, true) . '() <br/>
				{  <br/>
					&nbsp;&nbsp;&nbsp;    return $this->' . dashesToCamelCase($colname, false) . ';  <br/>
				} <br/> ';
            print $getFn;
            //print('<br/>');
            $setFn = 'public function set' . dashesToCamelCase($colname, true) . '($' . dashesToCamelCase($colname, false) . ') <br/>
				{  <br/>
					&nbsp;&nbsp;&nbsp;    $this->' . dashesToCamelCase($colname, false) . ' = $' . dashesToCamelCase($colname, false) . ';  <br/>
				} <br/> ';
            print $setFn;
        }
        $iterateVisible = ' public function iterateVisible() {  <br/>
			&nbsp;&nbsp;&nbsp;   $json = "{";  <br/>
			 
			&nbsp;&nbsp;&nbsp;   foreach($this as $key => $value) {  <br/>
			&nbsp;&nbsp;&nbsp;	 &nbsp;&nbsp;&nbsp;    $json .= "\\"".$key."\\":\\"".$value."\\",";  <br/>				
			&nbsp;&nbsp;&nbsp;   }  <br/>
			 
			&nbsp;&nbsp;&nbsp;   $json = substr($json, 0, -1); ;  <br/>
			  
			&nbsp;&nbsp;&nbsp;   $json .= "}";  <br/>
			 
			&nbsp;&nbsp;&nbsp;   return $json;  <br/>			
		}  <br/>';
        print $iterateVisible;
        print printImportMethod();
    }
    DbUtil::disconnect();
    //return $$colnameArray;
}