SitePoint Sponsor

User Tag List

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

Thread: Pragmatic MVC

  1. #51
    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 Hal9k
    It seems like I inadvertently opened a can of worms
    Yeah. Let's just leave it be.

    Quote Originally Posted by Hal9k
    private $SchemaModel;
    private means "only accessible from this class". protected means "only accessible from this class or it's descendants". It's unfortunate that private sounds like the natural counter to public - If you use private, you make it impossible (or hard) to extend the class. So as a rule of thumb - use protected and only resort to private in very special cases.

    Quote Originally Posted by Hal9k
    $this->Request->offsetGet('display')
    I assume that your requestwrapper implements ArrayAccess ? In that case, you could just do:
    PHP Code:
    $this->Request['display'
    Quote Originally Posted by Hal9k
    $this->SchemaModel->connectDatabase();
    You might want to pass the database connection to the model, rather than create it in the constructor. If you have multiple model's, you wouldn't have to open multiple connections. It would also allow you to use transactions.

    Quote Originally Posted by Hal9k
    $users =<<<EOD
    // sql here
    EOD;
    $this->Database->query($users);
    I prefer to put sql in class constants. It puts them in a single place. You could later decide to move them out into a data dictionary, which would make it possible to port your application to different rdbms's.

    In the nitpicking appartment; The common standard is to let variables begin with a small letter and capitalize succeeding words. Eg. $this->schemaModel. It's particularily important with variables, since PHP is case sensitive with variables.

  2. #52
    Afraid I can't do that Dave Hal9k's Avatar
    Join Date
    Mar 2004
    Location
    East Anglia, England.
    Posts
    640
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the quick reply!

    Quote Originally Posted by kyberfabrikken
    In the nitpicking appartment; The common standard is to let variables begin with a small letter and capitalize succeeding words. Eg. $this->schemaModel. It's particularily important with variables, since PHP is case sensitive with variables.
    My reason for doing this was to show what is an object, it's just a little convention I subconsciously use.

    I'll definitely make those other ammendments though.

    Edit:

    Made the changes and nothing breaks, which seems to be happening consistently; it's nice to have flexible code Cheers to everyone who posted in this thread, especially Kyber and Fenrir for providing an interesting counterpoint.


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
  •