*/ require_once('lib/debug/debugger-ext.php'); /** * \brief Debugger command to exec SQL */ class DbgSQLQuery extends DebuggerCommand { /// \b Must have function to announce command name in debugger console public function name() { return 'sql'; } /// \b Must have function to provide help to debugger console public function description() { return 'Exec SQL query on Tiki DB'; } /// \b Must have function to provide help to debugger console public function syntax() { return 'sql [sql-query]'; } /// \b Must have function to show example of usage of given command public function example() { return 'sql select * from tiki_preferences'; } /// Execute command with given set of arguments. public function execute($params) { // // Due to limitations of Smarty, I am forced to use // HTML_RESULT... (not fun!) // $this->set_result_type(HTML_RESULT); $this->set_result_tpl('debug/tiki-debug_sql.tpl'); // Init result $result = ''; // global $debugger; $debugger->msg('SQL query: "' . $params . '"'); // if (strlen(trim($params)) != 0) { global $tikilib; $qr = $tikilib->db->query($params); if (DB::isError($qr)) { $result = '' . $qr->getMessage() . ''; } else { // Check if result value an array or smth else if (is_object($qr)) { // Looks like 'SELECT...' return table to us... // So our result will be 2 dimentional array // with elements count and fields number for element // as dimensions... $first_time = true; $result = '
| ' . $key . ' | '; } $first_time = false; } $result .= '
| ' . $val . ' | '; $td_eo_class = ! $td_eo_class; } // $result .= '