/** * Database Schema: Execute Query * * @return void */ protected function executeQuery() { /* Get form */ $message = NULL; $form = new \IPS\Helpers\Form("database_table_execute"); $form->add(new \IPS\Helpers\Form\Codemirror('versions_sql_query', NULL, TRUE, array('mode' => 'sql'))); /* Has the form been submitted? */ if ($values = $form->values()) { $excTime = microtime(TRUE); $queryResult = \IPS\Db::i()->query($values['versions_sql_query']); $excTime = microtime(TRUE) - $excTime; $excTime = number_format(round($excTime, 2), 2); if ($queryResult === TRUE) { \IPS\Output::i()->redirect(\IPS\Http\Url::internal("app=core&module=applications&controller=developer&appKey={$this->application->directory}&tab=schema"), 'versions_sql_query_execution_success'); } $data = array(); foreach ($queryResult as $result) { $data[] = $result; } /** * I can't seem to find any reliable method of storing arbitrary data in a members database session, so for * right now we store results in a compressed base64 encoded cookie. This data is stored so that we can * offer sorting and (possibly pagination in the future) for database results. */ \IPS\Request::i()->setCookie('versions_sql_query_result', base64_encode(gzencode(json_encode(array('numRows' => $queryResult->num_rows, 'excTime' => $excTime, 'data' => $data)))), \IPS\DateTime::create()->add(new \DateInterval('PT1H'))); /** * If we get a result from MySQL (instead of just a success status), we send the output back * in a formatted table here. */ $table = new \IPS\Helpers\Table\Custom($data, \IPS\Http\Url::internal("app=core&module=applications&controller=developer&appKey={$this->application->directory}&do=executeQueryResult")); \IPS\Output::i()->breadcrumb[] = array(\IPS\Http\Url::internal("app=core&module=applications&controller=developer&appKey={$this->application->directory}&tab=schema"), 'dev_schema'); \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('versions_sql_query_result_count', TRUE, array('pluralize' => array($queryResult->num_rows), 'sprintf' => array($excTime))); \IPS\Output::i()->output = (string) $table; return; } /* If not, show it */ \IPS\Output::i()->output = (string) $form; }
/** * Get last comment time * * @note This should return the last comment time for this node only, not for children nodes * @return \IPS\DateTime|NULL */ public function getLastCommentTime() { return $this->last_marker_date ? \IPS\DateTime::ts($this->last_marker_date) : NULL; }