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'> <?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 "?><br/></div>"; print "<br/>"; } } DbUtil::disconnect(); return $tableArray; }
public function getAll() { $pdo = DbUtil::connect(); $dao = new M04ChapterDao($pdo); $objArray = $dao->getAll(); DbUtil::disconnect(); return CommonUtil::objArrayToJson($objArray); }
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 " private \$" . dashesToCamelCase($row['COLUMN_NAME'], false) . ";<br/>"; //print(" COl".$count++ ." > ".dashesToCamelCase($row['COLUMN_NAME'],false)."<br/>"); } foreach ($colnameArray as $colname) { $getFn = 'public function get' . dashesToCamelCase($colname, true) . '() <br/> { <br/> return $this->' . dashesToCamelCase($colname, false) . '; <br/> } <br/> '; print $getFn; //print('<br/>'); $setFn = 'public function set' . dashesToCamelCase($colname, true) . '($' . dashesToCamelCase($colname, false) . ') <br/> { <br/> $this->' . dashesToCamelCase($colname, false) . ' = $' . dashesToCamelCase($colname, false) . '; <br/> } <br/> '; print $setFn; } $iterateVisible = ' public function iterateVisible() { <br/> $json = "{"; <br/> foreach($this as $key => $value) { <br/> $json .= "\\"".$key."\\":\\"".$value."\\","; <br/> } <br/> $json = substr($json, 0, -1); ; <br/> $json .= "}"; <br/> return $json; <br/> } <br/>'; print $iterateVisible; print printImportMethod(); } DbUtil::disconnect(); //return $$colnameArray; }
/** * * @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; }
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'> <?php<br/>"; print 'namespace com\\numeracy\\facade; <br/>'; print " include_once '../util/DbUtil.php';<br/>\n\t\t\t\t\t\t\t include_once '../util/CommonUtil.php';<br/>"; print " //bo includes<br/>\n\t\t\t\t\t\t\t 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 // dao includes<br/>\n\t\t\t\t\t\t\t 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 // Util<br/>\n\t\t\t\t\t\t\t use com\\numeracy\\util\\DbUtil;<br/>\n\t\t\t\t\t\t\t use com\\numeracy\\util\\CommonUtil;<br/>\n\t\t\t\t\t\t\t<br/>\n\t\t\t\t\t\t\t use com\\numeracy\\BO\\" . dashesToCamelCase($tableName, true) . "BO;<br/>\n\t\t\t\t\t\t\t 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 "?><br/></div>"; print "<br/>"; } } DbUtil::disconnect(); return $tableArray; }
use com\numeracy\util\DbUtil; $error = 'test'; // Variable To Store Error Message if (isset($_POST['submit'])) { if (empty($_POST['inputEmail']) || empty($_POST['inputPassword'])) { $error = "Username or Password is invalid"; } else { // Define $username and $password $username = $_POST['inputEmail']; $password = $_POST['inputPassword']; $username = stripslashes($username); $password = stripslashes($password); //$username = mysql_real_escape_string($username); //$password = mysql_real_escape_string($password); $tableName = ""; $pdo = DbUtil::connect(); $sql = "SELECT M14LOGINID, USERNAME, PASSWORD, CREATEDON, CREATEDBY, MODIFIEDON, MODIFIEDBY FROM M14_LOGIN where username='******' AND password= '******' ORDER BY M14LOGINID DESC "; //$sql = "select * from login where username='******' AND password= '******' "; //$sql = "select table_name from information_schema.tables where table_schema='numeracy'"; //$sql ="DESCRIBE numeracy.m01_user"; $values = $pdo->query($sql); /* $stmt = $pdo->prepare($sql); $stmt->execute(array($username,$password)); $row = $stmt->fetch(PDO::FETCH_ASSOC); */ if ($values != null) { if (is_array($values) || is_object($values)) { foreach ($values as $row) { $tableName = $row['USERNAME']; }