Welcome Guest, Not a member yet? Register   Sign In
My routes aren't passing arguments
#1

[eluser]NSGReaper[/eluser]
So I'm currently working on the file download script for a site. Files can be downloaded either by using: http://mysite/download/34 or http://mysite/download/project.pdf. That is the plan at least, these should be routed to files/getbyid and files/getbyname respectively but while I know that the right function is called no arguments are being passed to it.

Code:
$route['download/:num'] = "files/getbyid";
$route['download/:any'] = "files/getbyname";

Code:
class Files extends Controller {
    function getbyid($id = -1)
    {
        if ($id = -1) {
            die("No file id specified");
        } else { echo $id; }
    }
    
    function getbyname($file = "")
    {
        if ($file = "") {
            die("No file name specified");
        } else { echo $file; }
    }
}

With it setup like this I always get the die() message. I have been able to make it work using regex like so:

Code:
$route['download/([0-9]*)'] = "files/getbyid/$1";
$route['download/(.*)'] = "files/getbyname/$1";


However it was my understanding that these were synonymous. Have I misunderstood the user guide or is something wrong?


Messages In This Thread
My routes aren't passing arguments - by El Forum - 09-24-2007, 08:39 AM
My routes aren't passing arguments - by El Forum - 09-24-2007, 08:51 AM
My routes aren't passing arguments - by El Forum - 09-24-2007, 09:05 AM
My routes aren't passing arguments - by El Forum - 09-24-2007, 01:47 PM
My routes aren't passing arguments - by El Forum - 09-24-2007, 11:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB