' . "\n";
// print an empty div, which will be later filled with
// the sql query results by ajax
$html .= '';
return $html;
}
/**
* Get initial values for Sql Query Form Insert
*
* @param string $query query to display in the textarea
*
* @return array ($legend, $query, $columns_list)
*
* @usedby self::getHtmlForInsert()
*/
public static function init($query)
{
$columns_list = array();
if (strlen($GLOBALS['db']) === 0) {
// prepare for server related
$legend = sprintf(
__('Run SQL query/queries on server ā%sā'),
htmlspecialchars(
! empty($GLOBALS['cfg']['Servers'][$GLOBALS['server']]['verbose'])
? $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['verbose']
: $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['host']
)
);
} elseif (strlen($GLOBALS['table']) === 0) {
// prepare for db related
$db = $GLOBALS['db'];
// if you want navigation:
$tmp_db_link = '';
$legend = sprintf(__('Run SQL query/queries on database %s'), $tmp_db_link);
if (empty($query)) {
$query = Util::expandUserString(
$GLOBALS['cfg']['DefaultQueryDatabase'], 'backquote'
);
}
} else {
$db = $GLOBALS['db'];
$table = $GLOBALS['table'];
// Get the list and number of fields
// we do a try_query here, because we could be in the query window,
// trying to synchronize and the table has not yet been created
$columns_list = $GLOBALS['dbi']->getColumns(
$db, $GLOBALS['table'], null, true
);
$tmp_tbl_link = '';
$tmp_tbl_link .= htmlspecialchars($db)
. '.' . htmlspecialchars($table) . '';
$legend = sprintf(__('Run SQL query/queries on table %s'), $tmp_tbl_link);
if (empty($query)) {
$query = Util::expandUserString(
$GLOBALS['cfg']['DefaultQueryTable'], 'backquote'
);
}
}
$legend .= ': ' . Util::showMySQLDocu('SELECT');
return array($legend, $query, $columns_list);
}
/**
* return HTML for Sql Query Form Insert
*
* @param string $query query to display in the textarea
* @param string $delimiter default delimiter to use
*
* @return string
*
* @usedby self::getHtml()
*/
public static function getHtmlForInsert(
$query = '', $delimiter = ';'
) {
// enable auto select text in textarea
if ($GLOBALS['cfg']['TextareaAutoSelect']) {
$auto_sel = ' onclick="selectContent(this, sql_box_locked, true);"';
} else {
$auto_sel = '';
}
$locking = '';
$height = $GLOBALS['cfg']['TextareaRows'] * 2;
list($legend, $query, $columns_list) = self::init($query);
if (! empty($columns_list)) {
$sqlquerycontainer_id = 'sqlquerycontainer';
} else {
$sqlquerycontainer_id = 'sqlquerycontainerfull';
}
$html = ''
. '