setQueryGrammar(new MySqlGrammar()); ///$sql = $connection->table('eb_user')->toSql(); // var_dump($connection->query($sql)); //var_dump($user); //$this->db->select('select sleep(1)'); //User::query('select sleep(3)'); $user = User::first(); return ['uid' => 33, 'username' => $user]; } /** * @RequestMapping(value="/user/{uid:\d+}") */ public function user(int $uid, Request $request, Response $response) { //BeanFactory::getBean(''); //$user = $this->db->select('select * from eb_user where id = 1'); return ['code' => 1, 'uid' => $uid]; } /** * @RequestMapping(value="/redirect") */ public function redirect(Request $request, Response $response) { $response->writeRedirect('http://www.baihand.com'); } /** * @RequestMapping(value="/user/json") * @Redis(key="name") */ public function json() { $user = $this->db->table('user')->get(); return ['code' => 1, 'msg' => 'success', 'data' => $user]; } /** * @Lock(prefix="lock",key="#0") * @RequestMapping(value="/user/lock/{uid:\d+}") */ public function lock(Request $request, $uid, Response $response) { return $this->db->table('user')->get(); } }