Jump to content

ckrudelux

Members
  • Posts

    565
  • Joined

  • Last visited

Everything posted by ckrudelux

  1. ckrudelux

    OOP and MYSQL

    My issue is I don't really know any good ways to populate my objects I came up with one but did feel like it was the best way of doing it. The way of PDO is one way but feels like it doesn't scope with the idea I read about the OOP. Feels like I take out the idea of using classname/interface with the argument in a method. Yes I could use a validation on the data but could I be sure I got the right data like I can be then asking for specific classname/interface. I can't find any good articles on the web of this topics either. Just haven't seen many example on doing this. :/
  2. ckrudelux

    OOP and MYSQL

    Didn't feel like I got a pleasing answer to what I was asking. Some one else got a point of view on how to get SQL data into the objects?
  3. $newfile = explode(".",$originalimg);array_pop($newfile);$newfile = implode(".",$newfile) . ".png";rename($originalimg, $newfile);
  4. What works until someone has .png in the filename and not as an extension. Try with explode and take away everything after the last dot.
  5. I see, just rename it to jpg or jpeg instead png or just change the name then saving the file and remove the old one.
  6. http://se2.php.net/rename
  7. ckrudelux

    OOP and MYSQL

    I want to be sure that the data getting in to the object is from the right table. This is why this row in this example is so special:public function __construct(CollectPersons $person=null){ It will only accept objects which are of the CollectPersons class as an argument, so I can be sure the data given is from the right table and not something that could look like the right data.
  8. ckrudelux

    OOP and MYSQL

    I looked in the manual and yes PDO::FETCH_CLASS is a good method but I can't see if it can populate private properties.Also I want some kind of filter so you can't populate wrong data by mistake. This is one method of doing this in one SQL query instead of many:<?phpclass Person { private $fname; private $lname; private $id; /** * * An empty constructor will create a new person. * */ public function __construct(CollectPersons $person=null){ if($person){ $this->fname = $person->getData()['fname']; $this->lname = $person->getData()['lname']; $this->id = $person->getData()['id']; } } public function getFname(){ return $this->fname; } public function getLname(){ return $this->lname; } public function getID(){ return $this->id; } public function setFname($fname){ $this->fname = $fname; } public function setLname($lname){ $this->lname = $lname; } } class CollectPersons { private $persons = array(); private $result; public function getPersons(){ if(empty($this->persons)){ if($query = mysql_query("SELECT * FROM `person`")){ while($row = mysql_fetch_assoc($query)){ $this->result = $row; $this->persons[] = new Person($this); } }else{ return false; } } return $this->persons; } public function getData(){ return $this->result; } } But as I stated out before this is the best solution I could come up with based on my design pattern I don't know if this approach is good at all or if there are better once regarding OOP.
  9. ckrudelux

    OOP and MYSQL

    I can't find anything about private properties, also I can't be sure if the data is the correct one this would be similar to sending an array or stdobj to the constructor. I would still need to send a object into my constructor so I would know that the data given is the correct one.
  10. ckrudelux

    OOP and MYSQL

    I've been thinking about how to populate my object how I does it now is each object fetch it's data from with in it self this results in many SQL requests which is bad. I've been thinking of doing some SQL query holding object which each get their data from. My question is what are my options to make less SQL requests and still get the data to the objects?
  11. This gives you some idea what you are after:http://www.youtube.com/watch?v=ZbBf4jfwWko
  12. I don't think jQuery would be bad for learning it offers a new point of view to the problem which might give you the perspective you need to understand the real deal.
  13. I think the blog entry popup should have a smaller maximum width for the text it's too wide now or bigger text.. But this is just my taste of how i like things and you could gain readers which have harder to read as well.
  14. Only changed the color in notepad++, I use the zoom function to make things bigger. Notepad++ has had some updates lately too. Why NetBeans and eclipse feels unstable is cause they are written in java. I find java applications to be slow which makes them crash ever now and then.
  15. Eclipse has a built in browser you can check the resualt in, just still need to switch between them but you don't have to have two windows open at the same time. I suggest you use notepad++ if you are one windows. I have a hard time replacing it with anything atm. Sublime has a could be a great editor if you which to get your hands dirty setting it up.. but the default settings works really good to, only bad thing about is that it cost money but you can still use it for free as a trial which brings a popup telling you to buy it kinda like winzip does trial never ends if I remember correctly.
  16. I just realized I haven't checked it out lately mostly cause I don't see any reason to use it, but in the beginning it was an wysiwyg editor which generated code for you. The code it generated was rubbish, I doubt it's any better today. I haven't tested out there text editor side but if that's all you need from the program then that would be waste of money. You should try any of these out: notepad++, sublime, NetBeans, eclipse and vim. Which probably does the job just as good or better then dreamweavers text editor.
  17. A good guide line is to avoid dreamweaver.
  18. ckrudelux

    printf function?

    Haha.. well it's a lot to take in so I do understand how hard it can be to understand some of the things. In the beginning maybe you just have to accept the facts, the clues on how things goes together will revel them self later on in your path to becoming a programmer. If you really want to find out what this does I suggest you try it out and see whats happen then you run it.
  19. ckrudelux

    printf function?

    You don't have to search I gave you the link and where to find it. You only need to scrolling down to the format section of that link. form the page I linked to you this is the part you want to read: and this is what you asked for: This is me telling you what it is and where you can find it
  20. ckrudelux

    printf function?

    It's a placeholder for a string and there are other versions of it you can read about them at the format section from this function sprintf on in the php manual: http://www.php.net/sprintf
  21. ops. didn't get all: Action:OpenFormArguments:_session; Form; ; "[_course]=" & [ID]; Edit; Normal
  22. ckrudelux

    printf function?

    I can't tell you to like the php manual but you get quite a lot of examples on how you could use the printf function which are submitted from other users. anyway printf is used to make life easier then adding variable content to a string for example: instead of doing this:$name = "Andreas";print("Hello ". $name ." ! How are you today?"); you could do this: $name = "Andreas";printf("Hello %s ! How are you today?", $name);
  23. This is the macro set by the wizard:"[_course]=" & [iD] Btw should mention what I'm using 2007 version of MS Access
  24. ckrudelux

    printf function?

    in your addressbar in your browser like this to be more clear:http://www.php.net/printf
×
×
  • Create New...