function generate() { $thisTable = $this->getTableObject(); $thisSqlEngine = new selectSQLGenerator($thisTable->getTableName(), $thisTable->getDatabase(), $thisTable->getFieldNameArray()); $sql = $thisSqlEngine->constructSQL($thisTable); return $sql; }
function generateSelectSQL() { $thisTable = $this->getTableObject(); $thisSqlEngine = new selectSQLGenerator($thisTable->getTableName(), $thisTable->getDatabase(), " * "); $sql = $thisSqlEngine->constructSQL($thisTable); $code = ""; $code .= "<?\n"; $code .= "\$initStartLimit = 0;\n"; $code .= "\$limitPerPage = 10;\n\n"; $code .= "\$startLimit = \$_REQUEST['startLimit'];\n"; $code .= "\$numberOfRows = \$_REQUEST['rows'];\n"; $code .= "\$sortBy = \$_REQUEST['sortBy'];\n"; $code .= "\$sortOrder = \$_REQUEST['sortOrder'];\n\n"; $code .= "if (\$startLimit==\"\")\n"; $code .= "{\n"; $code .= "\t\t\$startLimit = \$initStartLimit;\n"; $code .= "}\n\n"; $code .= "if (\$numberOfRows==\"\")\n"; $code .= "{\n"; $code .= "\t\t\$numberOfRows = \$limitPerPage;\n"; $code .= "}\n\n"; $code .= "if (\$sortOrder==\"\")\n"; $code .= "{\n"; $code .= "\t\t\$sortOrder = \"DESC\";\n"; $code .= "}\n"; $code .= "if (\$sortOrder == \"DESC\") { \$newSortOrder = \"ASC\"; } else { \$newSortOrder = \"DESC\"; }\n"; $code .= "\$limitQuery = \" LIMIT \".\$startLimit.\",\".\$numberOfRows;\n"; $code .= "\$nextStartLimit = \$startLimit + \$limitPerPage;\n"; $code .= "\$previousStartLimit = \$startLimit - \$limitPerPage;\n\n"; $code .= "if (\$sortBy!=\"\")\n"; $code .= "{\n"; $code .= "\t\t\$orderByQuery = \" ORDER BY \".\$sortBy.\" \".\$sortOrder;\n"; $code .= "}\n"; $code .= "\n\n"; $code .= "\$sql = \"" . $sql . "\".\$orderByQuery.\$limitQuery;" . $this->getLineEnder(); $code .= "\$result = MYSQL_QUERY(\$sql);" . $this->getLineEnder(); $code .= "\$numberOfRows = MYSQL_NUM_ROWS(\$result);\n\n"; $code .= "\n?>"; $this->appendToCode($code); }
function generateSelectSQL() { $thisTable = $this->getTableObject(); $thisSqlEngine = new selectSQLGenerator($thisTable->getTableName(), $thisTable->getDatabase(), " * "); $sql = $thisSqlEngine->constructSQL($thisTable); $code = ""; $code .= "<?\n"; $code .= ""; $code .= "\$this" . ucfirst($thisTable->getPrimaryKey()) . "FromForm = \$_REQUEST['" . NAME_FORM_FIELD_PREFIX . ucfirst($thisTable->getPrimaryKey()) . NAME_FORM_FIELD_SUFFIX . "'];\n"; $code .= "\$thisAction = \$_REQUEST['action'];\n"; $code .= "if (\$thisAction==\"Update\")\n"; $code .= "{\n"; $thisUpdateSqlEngine = new updateSQLGenerator($thisTable->getTableName(), $thisTable->getDatabase()); $sqlUpdate = $thisUpdateSqlEngine->constructSQL($thisTable); $code .= $this->getRetreiveFromFormCode("REQUEST"); $code .= "\t\$sqlUpdate = \"" . $sqlUpdate . "\";" . $this->getLineEnder(); $code .= "\t\$resultUpdate = MYSQL_QUERY(\$sqlUpdate);" . $this->getLineEnder(); $code .= "\techo \"<b>Record with Id \".\$this" . ucfirst($thisTable->getPrimaryKey()) . "FromForm.\" has been Updated<br></b>\";\n"; $code .= "\t\$this" . ucfirst($thisTable->getPrimaryKey()) . "FromForm = \"\";\n"; $code .= "}\n\n"; $code .= "if (\$thisAction==\"Insert\")\n"; $code .= "{\n"; $thisInsertSqlEngine = new insertSQLGenerator($thisTable->getTableName(), $thisTable->getDatabase()); $sqlInsert = $thisInsertSqlEngine->constructSQL($thisTable); $code .= $this->getRetreiveFromFormCode("REQUEST"); $code .= "\t\$sqlInsert = \"" . $sqlInsert . "\";" . $this->getLineEnder(); $code .= "\t\$resultInsert = MYSQL_QUERY(\$sqlInsert);" . $this->getLineEnder(); $code .= "\techo \"<b>Record has been inserted in Database<br></b>\";\n"; $code .= "\t\$this" . ucfirst($thisTable->getPrimaryKey()) . "FromForm = \"\";\n"; $code .= "}\n\n"; $code .= "if (\$thisAction==\"Delete\")\n"; $code .= "{\n"; $thisDeleteSqlEngine = new deleteSQLGenerator($thisTable->getTableName(), $thisTable->getDatabase()); $sqlDelete = $thisDeleteSqlEngine->constructSQL($thisTable); $code .= $this->getRetreiveFromFormCode("REQUEST"); $code .= "\t\$sqlDelete = \"" . $sqlDelete . "\";" . $this->getLineEnder(); $code .= "\t\$resultDelete = MYSQL_QUERY(\$sqlDelete);\n" . $this->getLineEnder(); $code .= "\techo \"<b>Record with Id \".\$this" . ucfirst($thisTable->getPrimaryKey()) . "FromForm.\" has been Deleted<br></b>\";\n"; $code .= "\t\$this" . ucfirst($thisTable->getPrimaryKey()) . "FromForm = \"\";\n"; $code .= "}\n\n"; $code .= "\$initStartLimit = 0;\n"; $code .= "\$limitPerPage = 10;\n\n"; $code .= "\$startLimit = \$_REQUEST['startLimit'];\n"; $code .= "\$numberOfRows = \$_REQUEST['rows'];\n"; $code .= "\$sortBy = \$_REQUEST['sortBy'];\n"; $code .= "\$sortOrder = \$_REQUEST['sortOrder'];\n\n"; $code .= "if (\$startLimit==\"\")\n"; $code .= "{\n"; $code .= "\t\t\$startLimit = \$initStartLimit;\n"; $code .= "}\n\n"; $code .= "if (\$numberOfRows==\"\")\n"; $code .= "{\n"; $code .= "\t\t\$numberOfRows = \$limitPerPage;\n"; $code .= "}\n\n"; $code .= "if (\$sortOrder==\"\")\n"; $code .= "{\n"; $code .= "\t\t\$sortOrder = \"DESC\";\n"; $code .= "}\n"; $code .= "if (\$sortOrder == \"DESC\") { \$newSortOrder = \"ASC\"; } else { \$newSortOrder = \"DESC\"; }\n"; $code .= "\$limitQuery = \" LIMIT \".\$startLimit.\",\".\$numberOfRows;\n"; $code .= "\$nextStartLimit = \$startLimit + \$limitPerPage;\n"; $code .= "\$previousStartLimit = \$startLimit - \$limitPerPage;\n\n"; $code .= "if (\$sortBy!=\"\")\n"; $code .= "{\n"; $code .= "\t\t\$orderByQuery = \" ORDER BY \".\$sortBy.\" \".\$sortOrder;\n"; $code .= "}\n"; $code .= "\n\n"; $code .= "\$sql = \"" . $sql . "\".\$orderByQuery.\$limitQuery;" . $this->getLineEnder(); $code .= "\$result = MYSQL_QUERY(\$sql);" . $this->getLineEnder(); $code .= "\$numberOfRows = MYSQL_NUM_ROWS(\$result);\n\n"; $code .= "\n?>"; $this->appendToCode($code); }
function generateGetDataFromDbForOneRowOOnPage() { $thisTable = $this->getTableObject(); $code = ""; $code .= "<?php\n"; $code .= "\$this" . ucfirst($thisTable->getPrimaryKey()) . " = \$_REQUEST['" . $thisTable->getPrimaryKey() . NAME_FORM_FIELD_SUFFIX . "']\n"; $code .= "?>\n"; $thisSqlEngine = new selectSQLGenerator($thisTable->getTableName(), $thisTable->getDatabase(), " * ", "", "", "", "", "", "y"); $sql = $thisSqlEngine->constructSQL($thisTable); $code .= "<?php\n"; $code .= "\$sql = \"" . $sql . "\";" . $this->getLineEnder(); $code .= "\$result = MYSQL_QUERY(\$sql);" . $this->getLineEnder(); $code .= "\$numberOfRows = MYSQL_NUMROWS(\$result);\n"; $code .= "if (\$numberOfRows==0) { \n?>\n\n"; $code .= LANG_SIMPLE_INSIDE_SORRY_NO_RECORDS_FOUND . "\n\n"; $code .= "<?php\n}\n"; $code .= "else if (\$numberOfRows>0) {\n\n"; $code .= $this->getCodeTab() . "\$i=0;\n"; $code .= $this->generateGetDataFromDbForOneRow(); $code .= "\n}\n"; $code .= "?>\n"; return $code; }