Jump to content


Staff Alumni
  • Posts

  • Joined

  • Last visited

Everything posted by keeB

  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?
  13. I'm 5'6. Always been a shortie. Keeb (short for keebler elf) has been my nickname since I was 6 or 7.
  14. Linux here. Eclipse+PHPEclipse+Web Server Platform =
  15. [code] <?php /** * @author: keeb * @description: return all sub directories from a directory *  */ function fileTypeFilter($path) { return glob($path . "/*"); } function isDirectory($directory) { return is_dir($directory); } $path = "/var/www/audio"; $subfolders = array(); $folders = fileTypeFilter($path); foreach ($folders as $sub) { if (isDirectory($sub)) { array_push ($subfolders, $sub); } } ?> [/code] $subfolders contains a list of the subfolders in the directory. Good luck ;)
  16. [!--quoteo(post=355945:date=Mar 17 2006, 03:22 PM:name=croakingtoad)--][div class=\'quotetop\']QUOTE(croakingtoad @ Mar 17 2006, 03:22 PM) [snapback]355945[/snapback][/div][div class=\'quotemain\'][!--quotec--] Okay, that makes sense but what about $array[1] ? When I use this code [code] foreach($array as $key => $row) {     print_r("$array[$key][0]<br />"); } [/code] It's just printing-- Array[0] Array[0] Array[0] Array[0] Array[0] Array[0] Array[0] Array[0] Array[0] Array[0] Array[0] Array[0] Array[0] Array[0] Array[0] Array[0] Array[0] etc.... [/quote] Dude.. you don't have a multi dimensional array, at all.. You have a single dimension array. Stop trying to [key][value].. its just Array[0] -> Array[137]
  17. Sorry dave.. it looks like i didn't complete it :X Add that to the bottom.. [= [code] <?php $result = mysql_query($query); while ( $data = mysql_fetch_row ( $result ) ) {     print "<pre>";         print_r ( $result );         print "</pre>"; } ?> [/code]
  18. You're not making much sense bud.. [code]<table border="1" align="center" cellpadding="0" cellspacing="0" width="760" style="border:0px;">[/code] ?? is that what you're talking about?
  19. change.. [code]$_SESSION['$category'] = $_POST['cat'];[/code] to.. [code]$_SESSION['category'] = $_POST['cat'];[/code] silly man :D
  20. You just asked for a pretty big chunk of a web application, I hope you are aware.. We don't really write whole scripts for people, that's not what this forum is about. We're here for advice.. and I have 2 pieces for you. a) Read up on mySQL and database normalization. b) Read up on basic PHP syntax and sessions. If you don't want to learn, you'd be better off just got and posting in the freelance forum and having someone do it for you, or paying someone $100 or something along those lines. Good luck, and if you have any specific questions, don't hesitate to ask..
  21. keeB


    [!--quoteo(post=355785:date=Mar 17 2006, 02:04 AM:name=tubs2222)--][div class=\'quotetop\']QUOTE(tubs2222 @ Mar 17 2006, 02:04 AM) [snapback]355785[/snapback][/div][div class=\'quotemain\'][!--quotec--] how do u make it so that a url turns into this "index.php?id=232" [/quote] index.php: [code] <a href="index.php?id=10">click me</a> <?php if ( $_GET['id'] ) {     print "<br><br>You said the ID was $id"; } ?> [/code] [=
  22. If you don't have any ideas it seems that you're in way over your head, wouldn't you agree? My suggestion is to get the backend completely mapped out, starting with the database.. Tables, Constraints, Indexes, Stored Procedures, Views, Triggers... that's the biggest effort.. a good database design will make everything else quite easy.. Good luck!
  • 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.