public function get() { if (!ajax) { \core::$inline_script[] = 'loaded_modules = {"' . uri . '":true};'; return node::create('div#main div#' . $this->get_page_selector(), ['data-url' => isset($_POST['url']) ? $_POST['url'] : '/' . uri], $this->get_view()); } else { \classes\ajax::inject('#main', 'append', '<div id="' . $this->get_page_selector() . '" data-url="' . (isset($_POST['url']) ? $_POST['url'] : '/' . uri) . '">' . $this->get_view() . '</div>', '#' . $this->get_page_selector()); } }
/** * @param $sql * @param array $params * @param bool $throwable * @return \PDOStatement */ static function query($sql, $params = [], $throwable = false) { // Attempt to reconnect if connection has gone away. if (!_db::connected()) { _db::reconnect(); } $prep_sql = _db::$con->prepare($sql); if (!empty($params)) { foreach ($params as $key => $val) { $prep_sql->bindValue($key, $val); } } try { $prep_sql->execute(); } catch (\PDOException $e) { $error = node::create('div.error_message.mysql', [], node::create('p', [], $e->getMessage() . \core::get_backtrace() . print_r(isset($prep_sql->queryString) ? $prep_sql->queryString : '', 1) . print_r($params, true))); if (ajax) { _ajax::inject('body', 'append', $error); if (!$throwable) { _ajax::do_serve(); die; } } else { echo $error; if (!$throwable) { die; } } } return $prep_sql; }
public function do_submit() { $type = !$this->get_primary_key() ? 'Added' : 'Updated'; _ajax::add_script('$(".bs-callout-info").remove()', true); _ajax::inject('#' . $_REQUEST['ajax_origin'], 'before', node::create('div.bs-callout.bs-callout-info.' . strtolower($type) . ' p', [], $type . ' successfully')); }