function getControllerContents($tableName) { print ' include_once \'../util/CrossBrowserHead.php\'; <br/> include_once \'../util/CommonUtil.php\';<br/> include_once \'../facade/' . dashesToCamelCase($tableName, true) . 'Facade.php\';<br/> <br/> // use PDO;<br/> use com\\numeracy\\util\\CommonUtil;<br/> use com\\numeracy\\facade\\' . dashesToCamelCase($tableName, true) . 'Facade;<br/> <br/> $data = json_decode ( file_get_contents ( "php://input" ) );<br/> <br/> $facade = new ' . dashesToCamelCase($tableName, true) . 'Facade();<br/> <br/> echo CommonUtil::excecuteCommand($facade,$data);<br/>'; }
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 * @param unknown $colnameArray * @return string */ function getCreate($tableName, $colnameArray) { $result = ''; $pos = strpos($tableName, '_'); $com = substr($tableName, 0, $pos); foreach ($colnameArray as $colname) { if ($com != null) { $tst = strpos($colname, $com); if (strlen($tst) > 0) { } else { $result .= '$obj->get' . dashesToCamelCase($colname, true) . '() , '; } } else { $result .= '$obj->get' . dashesToCamelCase($colname, true) . '() , '; } } $result = substr($result, 0, -2); return $result; }
function getAllFunction($tableName) { print 'public function getAll() {<br/> $pdo = DbUtil::connect ();<br/> $dao = new ' . dashesToCamelCase($tableName, true) . 'Dao ( $pdo );<br/> $objArray = $dao->getAll();<br/> DbUtil::disconnect ();<br/> return CommonUtil::objArrayToJson ( $objArray );<br/> }<br/>'; }