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"); }
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"); }
/** * */ 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"); }