public function search($request) { $DB = Dispatcher::getInstance()->get('db'); $q = $request->get('q'); if (!empty($q)) { $search = $DB->rawQuery('SELECT * FROM `search` WHERE q = "' . $q . '"')->toAssocArray(); if (!empty($search[0]['id'])) { $qid = $search[0]['id']; } else { echo 'esle'; echo $qid = $DB->rawQuery('INSERT INTO `search` (`q`) VALUES("' . $q . '")')->lastInsertId(); } echo $qid; // $URL = 'https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search='.$q.'&namespace=0&limit=10&suggest='; // $response = $this->extendedHttpRequest($URL, ['method' => 'GET']); // if($response->code === 200) // { // $responseArray = json_decode($response->data); // $resultArray = $DB->rawQuery('SELECT * FROM `search` WHERE q = "' . $q . '"')->toJson(); // } // echo $resultArray; } }
if (isset(Config::get('builder')['fe_css'])) { $di->get('builder')->setCSS(Config::get('builder')['fe_css']); } $di->get('builder')->assign("cabinet", Config::get('app')['cabinet']); /* * Config init */ $di->set('config', new Config()); /* * Database init */ $di->set('db', new Database(Config::get('db')['connection_string'], Config::get('db')['user'], Config::get('db')['pass'])); /* * HTTP Request init */ $di->set('request', new Request()); /* * SessionManager init */ $di->set('session', new Session())->start(); /* * Dispatcher init */ $dispatcher = new Dispatcher($di); $_post = isset($_POST) && is_array($_POST) && count($_POST) > 0 ? $_POST : null; $content = $dispatcher->execute($_GET, $_post); /* * Execution */ $di->get('builder')->assign('content', $content); $di->get('builder')->display();