Exemplo n.º 1
0
function getControllerContents($tableName)
{
    print ' &nbsp;&nbsp;&nbsp;    include_once \'../util/CrossBrowserHead.php\'; <br/>
					&nbsp;&nbsp;&nbsp;    include_once \'../util/CommonUtil.php\';<br/>
					&nbsp;&nbsp;&nbsp;    include_once \'../facade/' . dashesToCamelCase($tableName, true) . 'Facade.php\';<br/>
					&nbsp;&nbsp;&nbsp;    <br/>
					&nbsp;&nbsp;&nbsp;    // use PDO;<br/>
					&nbsp;&nbsp;&nbsp;    use com\\numeracy\\util\\CommonUtil;<br/>
					&nbsp;&nbsp;&nbsp;    use com\\numeracy\\facade\\' . dashesToCamelCase($tableName, true) . 'Facade;<br/>
					&nbsp;&nbsp;&nbsp;    <br/>
					&nbsp;&nbsp;&nbsp;    $data = json_decode ( file_get_contents ( "php://input" ) );<br/>
					&nbsp;&nbsp;&nbsp;    <br/>
					&nbsp;&nbsp;&nbsp;    $facade = new ' . dashesToCamelCase($tableName, true) . 'Facade();<br/>
					&nbsp;&nbsp;&nbsp;    <br/>
					&nbsp;&nbsp;&nbsp;    echo CommonUtil::excecuteCommand($facade,$data);<br/>';
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
0
/**
 * 
 * @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;
}
Exemplo n.º 4
0
function getAllFunction($tableName)
{
    print 'public function getAll() {<br/>
		
		&nbsp;&nbsp;&nbsp;   $pdo = DbUtil::connect ();<br/>
		
		&nbsp;&nbsp;&nbsp;   $dao = new ' . dashesToCamelCase($tableName, true) . 'Dao ( $pdo );<br/>
		
		&nbsp;&nbsp;&nbsp;   $objArray = $dao->getAll();<br/>
		
		&nbsp;&nbsp;&nbsp;   DbUtil::disconnect ();<br/>
		
		&nbsp;&nbsp;&nbsp;   return  CommonUtil::objArrayToJson ( $objArray );<br/>
	&nbsp;&nbsp;&nbsp;   }<br/>';
}