SitePoint Sponsor

User Tag List

Page 3 of 3 FirstFirst 123
Results 51 to 63 of 63

Thread: Request wrapper

  1. #51
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    > I take it, that you remember to stripslashes before running data through
    > mysql_real_escape_string, right?

    Some people are not using either

  2. #52
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Location
    Australia, Victoria
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wouldnt a foreach to loop through the requests be a bit of an overkill, what about a command like array_map();

  3. #53
    SitePoint Addict Jasper Bekkers's Avatar
    Join Date
    May 2007
    Location
    The Netherlands
    Posts
    282
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston View Post
    Some people are not using either
    magic_quotes_gpc = off + mssql seems plausible
    Quote Originally Posted by schnoodles View Post
    Wouldnt a foreach to loop through the requests be a bit of an overkill.
    I wouldn't quantify that as overkill, both solutions are fine.

  4. #54
    SitePoint Addict
    Join Date
    Feb 2006
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by schnoodles View Post
    Wouldnt a foreach to loop through the requests be a bit of an overkill, what about a command like array_map();
    array_map won't cover the array keys.

  5. #55
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    May be Request is to be Singleton? Why would we need it instantiated more than once?

  6. #56
    SitePoint Addict
    Join Date
    Nov 2005
    Location
    Germany
    Posts
    235
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by REMIYA View Post
    May be Request is to be Singleton? Why would we need it instantiated more than once?
    Does it hurt to have more than one instantiated? As the state of the Request instance is not being changed after construction, there should be no problem with more than one instance.

    Regards,
    Christoph

  7. #57
    SitePoint Addict been's Avatar
    Join Date
    May 2002
    Location
    Gent, Belgium
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by REMIYA View Post
    May be Request is to be Singleton? Why would we need it instantiated more than once?
    Maybe because we want to test it.
    Per
    Everything
    works on a PowerPoint slide

  8. #58
    SitePoint Addict Jasper Bekkers's Avatar
    Join Date
    May 2007
    Location
    The Netherlands
    Posts
    282
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by REMIYA View Post
    May be Request is to be Singleton? Why would we need it instantiated more than once?
    Because Singletons cause cancer.
    Design patterns: trying to do Smalltalk in Java.
    I blog too, you know.

  9. #59
    SitePoint Addict
    Join Date
    Nov 2005
    Location
    Germany
    Posts
    235
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by been View Post
    Maybe because we want to test it.
    The code for the Request object I've seen in this thread will make testing hard anyway, using the $_* global arrays directly within the constructor instead of passing them.

  10. #60
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by FrlB View Post
    The code for the Request object I've seen in this thread will make testing hard anyway, using the $_* global arrays directly within the constructor instead of passing them.
    You can't test the Request object itself, but you can test the code, which uses the request object. Only, if you use a global symbol to access the request object, you haven't really won anything.

  11. #61
    SitePoint Addict
    Join Date
    Nov 2005
    Location
    Germany
    Posts
    235
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken View Post
    You can't test the Request object itself, but you can test the code, which uses the request object.
    Seems there's misunderstanding. I think it's desirable to test the Request object itself--with an explicit passing of $_* arrays you can mock them without messing with the "real" $_REQUEST.
    PHP Code:
    $testRequest = new Request();
    //or
    $testRequest = new Request($myFakeRequestArray); 
    Additionally this will make testing code which uses the request object easier as well.
    I just do not agree with the following code
    PHP Code:
    public function __construct() {
            
    $this->request['get'] = $_GET;

    though I admit that passing every global array might be tiring.
    Quote Originally Posted by kyberfabrikken View Post
    Only, if you use a global symbol to access the request object, you haven't really won anything.
    Absolutely.

  12. #62
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by FrlB View Post
    Seems there's misunderstanding. I think it's desirable to test the Request object itself--with an explicit passing of $_* arrays you can mock them without messing with the "real" $_REQUEST.
    Whether you want to be testing the request object itself probably depends on if there is more functionality in there, than just a wrapper around the globals. If it's just that, then there is no point in testing the request object it self -- rather it provides the means to test the rest of the application.

  13. #63
    SitePoint Addict
    Join Date
    Nov 2005
    Location
    Germany
    Posts
    235
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken View Post
    You can't test the Request object itself, but you can test the code, which uses the request object.
    Seems there's misunderstanding. I think it's desirable to test the Request object itself--with an explicit passing of $_* arrays you can mock them without messing with the "real" $_REQUEST.
    PHP Code:
    $testRequest = new Request();
    //or
    $testRequest = new Request($myFakeRequestArray); 
    Additionally this will make testing code which uses the request object easier as well.
    I just do not agree with the following code
    PHP Code:
    public function __construct() {
            
    $this->request['get'] = $_GET;

    though I admit that passing every global array might be tiring.
    Quote Originally Posted by kyberfabrikken View Post
    Only, if you use a global symbol to access the request object, you haven't really won anything.
    Absolutely.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •