patch #2984058 [edit] Buttons for quicky creating common SQL queries.
Thanks to sutharshan, but the patch was heavily modified.
This commit is contained in:
@@ -61,6 +61,8 @@ $Id$
|
|||||||
- bug #2966752 [setup] Allow to configure changes tracking in setup script.
|
- bug #2966752 [setup] Allow to configure changes tracking in setup script.
|
||||||
+ patch #2981165 [edit] Optionally disable the Type column,
|
+ patch #2981165 [edit] Optionally disable the Type column,
|
||||||
thanks to Brian Douglass - bhdouglass
|
thanks to Brian Douglass - bhdouglass
|
||||||
|
+ patch #2984058 [edit] Buttons for quicky creating common SQL queries, thanks
|
||||||
|
to sutharshan.
|
||||||
|
|
||||||
3.3.3.0 (not yet released)
|
3.3.3.0 (not yet released)
|
||||||
- patch #2982480 [navi] Do not group if there would be one table in group,
|
- patch #2982480 [navi] Do not group if there would be one table in group,
|
||||||
|
@@ -1304,6 +1304,51 @@ function setSelectOptions(the_form, the_select, do_check)
|
|||||||
return true;
|
return true;
|
||||||
} // end of the 'setSelectOptions()' function
|
} // end of the 'setSelectOptions()' function
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create quick sql statements.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function insertQuery(queryType) {
|
||||||
|
var myQuery = document.sqlform.sql_query;
|
||||||
|
var myListBox = document.sqlform.dummy;
|
||||||
|
var query = "";
|
||||||
|
var table = document.sqlform.table.value;
|
||||||
|
|
||||||
|
if (myListBox.options.length > 0) {
|
||||||
|
sql_box_locked = true;
|
||||||
|
var chaineAj = "";
|
||||||
|
var valDis = "";
|
||||||
|
var editDis = "";
|
||||||
|
var NbSelect = 0;
|
||||||
|
for (var i=0; i < myListBox.options.length; i++) {
|
||||||
|
NbSelect++;
|
||||||
|
if (NbSelect > 1) {
|
||||||
|
chaineAj += ", ";
|
||||||
|
valDis += ",";
|
||||||
|
editDis += ",";
|
||||||
|
}
|
||||||
|
chaineAj += myListBox.options[i].value;
|
||||||
|
valDis += "[value-" + NbSelect + "]";
|
||||||
|
editDis += myListBox.options[i].value + "=[value-" + NbSelect + "]";
|
||||||
|
}
|
||||||
|
if (queryType == "selectall") {
|
||||||
|
query = "SELECT * FROM `" + table + "` WHERE 1";
|
||||||
|
} else if (queryType == "select") {
|
||||||
|
query = "SELECT " + chaineAj + " FROM `" + table + "` WHERE 1";
|
||||||
|
} else if (queryType == "insert") {
|
||||||
|
query = "INSERT INTO `" + table + "`(" + chaineAj + ") VALUES (" + valDis + ")";
|
||||||
|
} else if (queryType == "update") {
|
||||||
|
query = "UPDATE `" + table + "` SET " + editDis + " WHERE 1";
|
||||||
|
} else if(queryType == "delete") {
|
||||||
|
query = "DELETE FROM `" + table + "` WHERE 1";
|
||||||
|
}
|
||||||
|
document.sqlform.sql_query.value = query;
|
||||||
|
sql_box_locked = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts multiple fields.
|
* Inserts multiple fields.
|
||||||
*
|
*
|
||||||
|
@@ -296,6 +296,16 @@ function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false, $delimiter
|
|||||||
.' rows="' . $height . '"'
|
.' rows="' . $height . '"'
|
||||||
.' dir="' . $GLOBALS['text_dir'] . '"'
|
.' dir="' . $GLOBALS['text_dir'] . '"'
|
||||||
.$auto_sel . $locking . '>' . htmlspecialchars($query) . '</textarea>' . "\n";
|
.$auto_sel . $locking . '>' . htmlspecialchars($query) . '</textarea>' . "\n";
|
||||||
|
// Add buttons to generate query easily for select all,single select,insert,update and delete
|
||||||
|
if(count($fields_list)) {
|
||||||
|
?>
|
||||||
|
<input type='button' value='<?php echo __('Select all'); ?>' id='selectall' onclick='insertQuery(this.id)' />
|
||||||
|
<input type='button' value='<?php echo __('Select'); ?>' id='select' onclick='insertQuery(this.id)' />
|
||||||
|
<input type='button' value='<?php echo __('Insert'); ?>' id='insert' onclick='insertQuery(this.id)' />
|
||||||
|
<input type='button' value='<?php echo __('Update'); ?>' id='update' onclick='insertQuery(this.id)' />
|
||||||
|
<input type='button' value='<?php echo __('Delete'); ?>' id='delete' onclick='insertQuery(this.id)' />
|
||||||
|
<?php
|
||||||
|
}
|
||||||
echo '</div>' . "\n";
|
echo '</div>' . "\n";
|
||||||
|
|
||||||
echo '<script type="text/javascript">' . "\n"
|
echo '<script type="text/javascript">' . "\n"
|
||||||
|
Reference in New Issue
Block a user