Пример #1
0
 function preformSearch()
 {
     $sql = $this->buildQuery();
     $SweetDB_query = new SweetDB_query();
     $SweetDB_query->setupTextArea($sql);
     $queryArray = $SweetDB_query->runQuery($sql, 50);
     $this->sugar_smarty->assign("ACTIONS", $queryArray['actions']);
     $this->sugar_smarty->assign("QUERY_TIME", $queryArray['query_time']);
     $SweetDB_query->drawTableData($sql, $queryArray);
     $this->sugar_smarty->assign('EDIT_COMMAND', 'edit');
     $this->sugar_smarty->assign('DELETE_COMMAND', 'delete');
     $this->sugar_smarty->display("custom/modules/Administration/SweetDBAdmin/tpls/SweetDBQuery.tpl");
 }
Пример #2
0
 function describeTable()
 {
     global $sugar_config;
     $tableSelect = $this->getRequestVar('tableselect');
     if (empty($tableSelect)) {
         return null;
     }
     $ucaseDBUser = strtoupper($sugar_config['dbconfig']['db_user_name']);
     $ucaseTableName = strtoupper($tableSelect);
     $db_type = array('ibm_db2' => "SELECT * FROM SYSCAT.COLUMNS WHERE TABSCHEMA = '{$ucaseDBUser}' AND TABNAME = '{$ucaseTableName}'", 'mysql' => "DESCRIBE {$tableSelect}", 'SQL Server' => "sp_columns_90 {$tableSelect}", 'oci8' => "SELECT * FROM user_tab_columns WHERE TABLE_NAME = '" . strtoupper($tableSelect) . "'");
     $sql = $db_type[$sugar_config['dbconfig']['db_type']];
     $SweetDB_query = new SweetDB_query();
     $SweetDB_query->setupTextArea($sql);
     $queryArray = $SweetDB_query->runQuery($sql, 5000);
     //$this->sugar_smarty->assign("ACTIONS", $queryArray['actions']);
     $SweetDB_query->drawTableData($sql, $queryArray);
     $this->sugar_smarty->assign('EDIT_COMMAND', 'edit');
     $this->sugar_smarty->assign('DELETE_COMMAND', 'delete');
     $this->sugar_smarty->display("custom/modules/Administration/SweetDBAdmin/tpls/SweetDBQuery.tpl");
 }
Пример #3
0
 function display_indexes()
 {
     $indexes = $this->get_indicies($this->getTable());
     $i = 0;
     $rows = array();
     foreach ($indexes as $name => $data) {
         $fields = implode(', ', $data['fields']);
         $rows[$i] = array('id' => $data['name'], 'type' => $data['type'], 'fields' => $fields);
         $i++;
     }
     $queryArray['data'] = $rows;
     $queryArray['actions'] = true;
     $queryArray['header'] = array('Name', 'Type', 'Fields');
     $queryArray['main'] = '';
     $queryArray['extra_controls'] = "Select table to query:";
     $tableNameOptions = $this->getFullTableOptions();
     $queryArray['extra_controls'] .= "<select name=tableselect onchange=\"chooseNewTable('indexes');\">";
     $queryArray['extra_controls'] .= $tableNameOptions;
     $add_index_link = "index.php?module=Administration&action=SweetDBAdmin&skip=0&sql=&command=add_index&currentTable={$this->getTable()}";
     $queryArray['extra_controls'] .= "</select>&nbsp;<input type=button name=add value='Add Index' onclick='document.location=\"{$add_index_link}\"'>";
     $this->sugar_smarty->assign("ACTIONS", $queryArray['actions']);
     $sql = "HIDE";
     $SweetDB_query = new SweetDB_query();
     $SweetDB_query->setupTextArea($sql);
     $SweetDB_query->drawTableData($sql, $queryArray);
     $this->sugar_smarty->assign('EDIT_COMMAND', 'edit_index');
     $this->sugar_smarty->assign('DELETE_COMMAND', 'delete_index');
     $this->sugar_smarty->display("custom/modules/Administration/SweetDBAdmin/tpls/SweetDBQuery.tpl");
 }
Пример #4
0
 /**
  *
  */
 function save_record()
 {
     $sql = $this->buildSave();
     $SweetDB_query = new SweetDB_query();
     $numOfRecords = $this->getRequestVar('numrecords', 50);
     $queryArray = $SweetDB_query->runQuery($sql, -1);
     $table = $this->getTable();
     if (isset($_REQUEST['id_input'])) {
         $id = $_REQUEST['id_input'];
         $id_field = 'id';
     }
     if (isset($_REQUEST['id_c_input'])) {
         $id = $_REQUEST['id_c_input'];
         $id_field = 'id_c';
     }
     $newQuery = $this->getRequestVar('sql', '');
     if (empty($newQuery)) {
         $newQuery = "SELECT * FROM {$table} WHERE {$id_field}='{$id}'";
     }
     $queryArray2 = $SweetDB_query->runQuery($newQuery, $numOfRecords);
     $queryArray2['affectedRows'] = $queryArray['affectedRows'];
     $SweetDB_query->setupTextArea($sql);
     $this->sugar_smarty->assign("ACTIONS", $queryArray2['actions']);
     $this->sugar_smarty->assign("QUERY_TIME", $queryArray2['query_time']);
     $SweetDB_query->drawTableData($sql, $queryArray2);
     $this->sugar_smarty->assign('EDIT_COMMAND', 'edit');
     $this->sugar_smarty->assign('DELETE_COMMAND', 'delete');
     $this->sugar_smarty->display("custom/modules/Administration/SweetDBAdmin/tpls/SweetDBQuery.tpl");
 }