panique/mini

How to send a get parameter to a method in a controller?

Closed this issue · 6 comments

How to send a get parameter to a method in a controller?

Hey, check this area of the readme, it explains this, it's super easy !
https://github.com/panique/mini#quick-start

example.com/songs/editsong/17 will do what the editsong() method in application/controllers/songs.php says and will pass 17 as a parameter to it.

ezvr commented

is it possible to pass two or more parameters to the method? for example creating an API, which has several arguments, maybe how many values, and which database to get the values from..

Good question, can you plz try out if this works (I dont have a dev computer right now here):

as URL
example.com/songs/editsong/17/abc

and in https://github.com/panique/mini/blob/master/application/controller/songs.php use two parameters in the controller method, like public function editSong($song_id, $something)

Method 2: maybe simply use POST routes, like the delete/edit controller methods like public function addSong($artist, $track, $link) in https://github.com/panique/mini/blob/master/application/model/model.php

Hope it works out well for you :)

ezvr commented

Dear panique, thanks for your reply! I actually ended up implementing this using the _GET params inside my model functions, as such: $location = $_GET['location']; for url?location=XXX