Jump to content

keeB

Staff Alumni
  • Posts

    1,075
  • Joined

  • Last visited

About keeB

  • Birthday 08/29/1985

Contact Methods

  • AIM
    nickstinemates
  • MSN
    nickistotally@live.com
  • Website URL
    http://nick.stinemates.org/wordpress/
  • Yahoo
    nickstinemates@yahoo.com

Profile Information

  • Gender
    Male
  • Location
    California

keeB's Achievements

Member

Member (2/5)

0

Reputation

  1. Why do you need to add/remove photos? Just set the photo list once it's been open: <?php class User { private $photos = null; // this could also be PhotoList (or Gallery) if you want to have operations done on an entire set of photos. That's what I would recommend. private $userId = null; public function setPhotos($photos) { $this->photos = $photos; } public function getPhotos() { return $this->photos; } } ?>
  2. I didn't say a User could not have Photo's, I said that operations and data associated with photos should belong to photos.
  3. In that photos belong to a user? Sure. But they don't belong in the same object, nor does the handling of them.
  4. Well, I guess now you know why we kept telling you to take these methods out of the User class where they do not belong That would be terrible and illegible. What you're looking, honestly, is to create a few Model[1] Objects. <?php class UserPhotos { private $description = null; private $photo = null; private $address = null; public function setAddress($address) { $this->address = $address ; } public function addPhoto(Photo $photo) { $this->photos[] = $photo; //only on display should you care about limiting the amount of photos a user can have, or when you try to save. The responsibility doesn't need to be here. } public function setDescription(array $description) { $this->description = $description; } } [1]: http://en.wikipedia.org/wiki/Model_Object
  5. You don't. Name your classes more specifically and you won't have naming issues.
  6. Sound advice here. Just make a db.inc and include it in whichever page you need a database connection. Then, you can just call say $result = mysql_query("SELECT * FROM LOLO;", $db /* this is the resource created in db.inc */); Cheers
  7. Your explanation makes me feel like whatever you just did is not OK. While you can pass objects around, child objects aren't supposed to care about their implementation, just use them to accomplish their own goals. Objects should be very selfish. $this->user->login($this->input->sanitize($this->input->getPOST('username')) This is a classic case of no! Why should your user object care about how to authenticate? It should only know some basic things, like first name/last name and any real associated attributes. You could then have an Authentication module which accepts a User object to do the login. Here's an example <?php //model object, which is really just a namespace with accessors class User { private $firstname; private $lastname; private $username; private $password; private $userId; //associated getFirstName() and setFirstName() methods.. etc } class Authentication { public static function authenticateUser(User $user) { // do whatever authentication you want done here. } } ?> Next, and this is a minor gripe, but data should be passed around sanitized, and you're going to realize you're going to have $input->sanitize($some_data) All over your code. You should have a private sanitize method which sanitizes any type of input for consumption in the Input class. That's awesome. But make it transparent and done whenever the data is set. If you have any other questions we'll be happy to answer them.
  8. I'm a bad dev, I usually use svn to update my sites I was just adding some lunix flavor to this windows thread.
  9. keeb@urmom:# ftp myhost.org ^ best ftp client in the world.
  10. Debugging with XDebug within Eclipse is pretty amazing with projects of any relative complexity. That, and project management has been unmatched in the many IDE's I have tried (Netbeans PHP Plugin, Geany, Kate, Vim (Love vim, just no project support (that i know of)) I have seen some pretty amazing things that Emacs can do, but their control scheme is way too crazy for me.
  11. Nick, 22, Programming for 13 years. Started in Basic.
  12. Why a circle? Never seen this before?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.