mySQL Database Query Builder done
Esse commit está contido em:
+29
-3
@@ -31,9 +31,10 @@
|
||||
<input type='button' value='show projects' onclick="showProjects()"/>
|
||||
<input type='button' value='show users' onclick="showUsers()"/>
|
||||
<input type='button' value='analyze project demo_en' onclick="analyzeX()"/>
|
||||
<input type='button' value='commit project demo_en' onclick="commit()"/>
|
||||
<input type='button' value='show queries' onclick="showQueries()"/>
|
||||
<input type='button' value='logoff' onclick="logoff()"/>
|
||||
<pre><div id='result' style='white-space:pre;'></div></pre>
|
||||
<pre><div id='result' style='border:dashed 1px #777;'></div></pre>
|
||||
</body>
|
||||
<script>
|
||||
function setLoading()
|
||||
@@ -136,8 +137,33 @@
|
||||
type:'POST',
|
||||
url:'../../',
|
||||
data:{
|
||||
program:'analyze',
|
||||
commit:true
|
||||
program:'analyze'//,
|
||||
//commit:true
|
||||
},
|
||||
success: function(ret){
|
||||
document.getElementById('result').innerHTML= ret;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
function commit()
|
||||
{
|
||||
setLoading();
|
||||
$.ajax({
|
||||
type:'POST',
|
||||
url:'../../',
|
||||
data:{
|
||||
program:'use',
|
||||
what:'project',
|
||||
name:'demo_en'
|
||||
},
|
||||
success: function(ret){
|
||||
$.ajax({
|
||||
type:'POST',
|
||||
url:'../../',
|
||||
data:{
|
||||
program:'commit'
|
||||
},
|
||||
success: function(ret){
|
||||
document.getElementById('result').innerHTML= ret;
|
||||
|
||||
@@ -10,6 +10,102 @@
|
||||
*
|
||||
* @author felipe
|
||||
*/
|
||||
class mysql {
|
||||
//put your code here
|
||||
class mysql implements DBMS{
|
||||
|
||||
public function createDefault()
|
||||
{
|
||||
return "DEFAULT <defaultvalue>";
|
||||
}
|
||||
|
||||
public function property()
|
||||
{
|
||||
return "<property><propertyname></property> <propertytype><propertysize> <propertydetails>";
|
||||
}
|
||||
|
||||
public function createOptionsCheck()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public function notNullDefinition()
|
||||
{
|
||||
return "NOT NULL";
|
||||
}
|
||||
|
||||
public function autoIncrementType()
|
||||
{
|
||||
return "int";
|
||||
}
|
||||
|
||||
public function createUnique()
|
||||
{
|
||||
return "UNIQUE";
|
||||
}
|
||||
|
||||
public function getHeader()
|
||||
{
|
||||
$author= substr($_SESSION['login'], 0, 30);
|
||||
$author= str_pad($author, 30);
|
||||
$header= "<comment> -".str_pad('', 60, '-')."----
|
||||
--| ".str_pad("Generated by theWebMind project(mind3rd release)", 58)."|--
|
||||
--| ".str_pad("DBMS: ".str_pad('MySQL', 34)."Date: ". date('d/m/Y'), 58)."|--
|
||||
--| ".str_pad("Generator Author: Felipe Nascimento de Moura", 58)."|--
|
||||
--| ".str_pad("Source Author: ".$author, 58)."|--
|
||||
";
|
||||
$header.= " -".str_pad('', 60, '-')."----
|
||||
--".str_pad(strtoupper(Mind::$currentProject['name']).
|
||||
" (version ".Mind::$currentProject['version'].")",
|
||||
61, ' ', STR_PAD_BOTH)."--
|
||||
--".str_pad('', 60, '-')."---</comment>
|
||||
";
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function createFK()
|
||||
{
|
||||
return "
|
||||
<keyword>ALTER </keyword><object>TABLE</object> <tablename>
|
||||
<keyword>ADD</keyword> <object>CONSTRAINT</object> <constraintname>
|
||||
<object>FOREIGN KEY (<propertyname>)</object> <keyword>REFERENCES </keyword>
|
||||
<referencetablename>(<referencecolumnname>);
|
||||
";
|
||||
}
|
||||
|
||||
public function createPrimaryKeys()
|
||||
{
|
||||
return "
|
||||
<object>CONSTRAINT</object> <fkname> <object>PRIMARY KEY</object> (<propertienames>)
|
||||
";
|
||||
}
|
||||
|
||||
public function createPK()
|
||||
{
|
||||
return "
|
||||
<keyword>ALTER</keyword> <object>TABLE</object> <tablename>
|
||||
<keyword>ADD</keyword> <object>PRIMARY KEY</object> (<propertienames>);
|
||||
";
|
||||
}
|
||||
|
||||
public function createAutoIncrement()
|
||||
{
|
||||
return "AUTO_INCREMENT";
|
||||
}
|
||||
|
||||
public function createTable()
|
||||
{
|
||||
return "
|
||||
<keyword>CREATE </keyword><object>TABLE</object> <tablename>
|
||||
(
|
||||
<properties>
|
||||
<primarykeys>
|
||||
);
|
||||
";
|
||||
}
|
||||
|
||||
public function getModel($keyword)
|
||||
{
|
||||
if(method_exists($this, $keyword))
|
||||
return $this->$keyword();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -51,13 +51,19 @@ class pgsql implements DBMS{
|
||||
{
|
||||
$author= substr($_SESSION['login'], 0, 30);
|
||||
$author= str_pad($author, 30);
|
||||
return"<comment>#".str_pad('', 60, '#')."
|
||||
# ".str_pad("Generated by theWebMind(mind3rd release)", 58)."#
|
||||
# ".str_pad("DBMS: PostgreSQL Date: ". date('d/m/Y'), 58)."#
|
||||
# ".str_pad("Generator Author: Felipe Nascimento de Moura", 58)."#
|
||||
# ".str_pad("Source Author: ".$author, 58)."#
|
||||
#".str_pad('', 60, '#')."</comment>
|
||||
$header= "<comment> -".str_pad('', 60, '-')."----
|
||||
--| ".str_pad("Generated by theWebMind project(mind3rd release)", 58)."|--
|
||||
--| ".str_pad("DBMS: ".str_pad('PostgreSQL', 34)."Date: ". date('d/m/Y'), 58)."|--
|
||||
--| ".str_pad("Generator Author: Felipe Nascimento de Moura", 58)."|--
|
||||
--| ".str_pad("Source Author: ".$author, 58)."|--
|
||||
";
|
||||
$header.= " -".str_pad('', 60, '-')."----
|
||||
--".str_pad(strtoupper(Mind::$currentProject['name']).
|
||||
" (version ".Mind::$currentProject['version'].")",
|
||||
61, ' ', STR_PAD_BOTH)."--
|
||||
--".str_pad('', 60, '-')."---</comment>
|
||||
";
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function createFK()
|
||||
@@ -85,6 +91,11 @@ class pgsql implements DBMS{
|
||||
";
|
||||
}
|
||||
|
||||
public function createAutoIncrement()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public function createTable()
|
||||
{
|
||||
return "
|
||||
|
||||
@@ -54,11 +54,18 @@ class Query {
|
||||
// parsing te default value
|
||||
if(!empty($prop['default_value']))
|
||||
{
|
||||
$default= QueryFactory::getQueryString('createDefault');
|
||||
|
||||
$details[]= preg_replace(self::PROP_DEFAULT,
|
||||
$prop['default_value'],
|
||||
$default);
|
||||
if(\AUTOINCREMENT_DEFVAL == $prop['default_value'])
|
||||
{
|
||||
$details[]= QueryFactory::getQueryString('createAutoIncrement');
|
||||
$prop['default_value']= false;
|
||||
}else{
|
||||
$default= QueryFactory::getQueryString('createDefault');
|
||||
$def= \addslashes($prop['default_value']);
|
||||
$def= preg_replace(\BETWEEN_QUOTES, "'", trim($def));
|
||||
$details[]= preg_replace(self::PROP_DEFAULT,
|
||||
$def,
|
||||
$default);
|
||||
}
|
||||
}
|
||||
|
||||
// checking the not null attribute
|
||||
@@ -110,7 +117,6 @@ class Query {
|
||||
if($prop['default_value'] == \AUTOINCREMENT_DEFVAL)
|
||||
{
|
||||
$prop['type']= QueryFactory::getQueryString('autoIncrementType');
|
||||
$prop['default_value']= false;
|
||||
}
|
||||
|
||||
if($prop['size'])
|
||||
@@ -124,7 +130,7 @@ class Query {
|
||||
|
||||
$propQuery= preg_replace(self::PROP_TYPE, $prop['type'], $propQuery);
|
||||
|
||||
$tmpQuery.= $propQuery."\n ";
|
||||
$tmpQuery.= trim($propQuery).",\n ";
|
||||
}
|
||||
|
||||
$query= preg_replace(self::PROPS, trim($tmpQuery), $query);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
define('FIX_PROP_NAME', "/\\\|\,|\./");
|
||||
define('IMPORT_SOURCE', "/@import [a-z0-9_\-\/\\\]+/i");
|
||||
define('PROP_FIX', "((\(|[\., \n]))?+|\:");
|
||||
define('BETWEEN_QUOTES', "/^(\\\)\"|(\\\)\"$/");
|
||||
|
||||
// addresses
|
||||
define('PROJECTS_DIR', '/mind3rd/projects/');
|
||||
@@ -37,7 +38,7 @@
|
||||
define('QUANTIFIER_MAX_MAX', 'n');
|
||||
define('QUANTIFIER_MAX_MIN', 1);
|
||||
define('PROPERTY_SEPARATOR', "_");
|
||||
define('AUTOINCREMENT_DEFVAL', 0123);
|
||||
define('AUTOINCREMENT_DEFVAL', 'AUTO');
|
||||
define('COMMIT_STATUS_OK' , 0);
|
||||
define('COMMIT_STATUS_CHANGED',1);
|
||||
define('COMMIT_STATUS_DROP', 2);
|
||||
Referência em uma Nova Issue
Bloquear um usuário