-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Obtaining QueryString Data #35
Comments
Hello, use Laminas\Diactoros\ServerRequest;
class SearchController {
function index(ServerRequest $request) {
$keyword = $request->getQueryParams()['keyword'];
// Search $keyword in database or anywhere else...
// return response as view or json, etc.
}
} |
Great thank you I will look at that later
…On Fri, 12 Mar 2021, 07:23 Milad Rahimi, ***@***.***> wrote:
Hello,
The ?keyword=mike and everything after ? is called Query String and is
not part of route.
As for your search route /admin/search/?keywork={keyword}, the route
should be /admin/search and it can be mapped to controller like
SearchController::index().
To catch the query string (keywork={keyword}) you can do something like
the following code:
use Laminas\Diactoros\ServerRequest;
class SearchController {
function index(ServerRequest $request) {
$keyword = $request->getQueryParams()['keyword'];
// Search $keyword in database or anywhere else...
// return response as view or json, etc.
}
}
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#35 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHKAGFHJOK3C7CSAOKU4THLTDG6QLANCNFSM4YZU2KJQ>
.
|
Hi So as of now i am still using your Router ive been out of it for a while however it seems that $keyword = $request->getQueryParams()['keyword']; this no longer works ansd gives Undefined array key "id" , i have changed the word keyword to id. i have tried wrapping it in an iseset and nothing seems to be changing has something changed on yours or laminas side for this to not work anymore |
what do u get when print_r($request->getQueryParams()) ? |
cant see it in your documentation but does the routing support using ?keyword=mike im trying to setup a search page for users and it doesnt seem to be picking up and results to the catch and gives my custom error page which is just page not found
my form path is : /admin/search and then as a get method throws up ?keyword=
my route at the moment as i thought it might work is /admin/search/?keywork={keyword}
tia
The text was updated successfully, but these errors were encountered: