Jump to content

ckrudelux

Members
  • Posts

    565
  • Joined

  • Last visited

Posts posted by ckrudelux

  1. I'm not clear on what your problems are. It's easy to get data from your database into an object, what else are you trying to do that's causing a problem? It sounds like you have an issue with verification.
    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. 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. Thanks do you have example
    $newfile = explode(".",$originalimg);array_pop($newfile);$newfile = implode(".",$newfile) . ".png";rename($originalimg, $newfile);

    • Like 1
  4. ok i done this is it correct or is there a better way??
    $srcImg = imagecreatefrompng($originalimg);	imagejpeg($srcImg,$originalimg,100);	imagedestroy($srcImg);	$NewName = str_replace(".png",".jpg",$originalimg);	rename($originalimg,$NewName);

    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. yes i looked at that but if the file name changes like
    $originalimg = $_GET['img']; $srcImg = imagecreatefrompng($originalimg);		imagejpeg($srcImg,$originalimg,100);		imagedestroy($srcImg);

    how would i just change the extension from .png to .jpg but keep the file name the same

    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. hi guys have this code which works file but i need to rename the file after its converted (xxxx.png to xxxx.jpg)
    $originalimg = test.png $srcImg = imagecreatefrompng($originalimg);	imagejpeg($srcImg,$originalimg,100);	imagedestroy($srcImg);

    http://se2.php.net/rename
  7. What do you mean? the data is already coming from your database rather than getting it in array by looping it. you can use fetchAll() which will return an array of of the object of the specified class.
    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. have you yet check the manual about it? sorry, this the correct link.http://au.php.net/ma...ement.fetch.php what properties are you referring? can you elaborate more? what are you trying to do actually?
    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. if you use pdo there is option to fetch data as object setting fetching mode using PDO::FETCH_CLASS or PDO::FETCH_OBJhttp://php.net/pdo.fetch <=PDOstatement::fetch()
    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. 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?

    • Like 1
  11. << Topic pinned >> I've pinned it for now, and also, if you don't mind... I've made some "headers" for the sake of easier reading. Maybe we can rework it later, but this is good even like that. BTW, I think exactly like that, and used to think anyone who ever went into programming thinks in the same way, but after seeing Temple Grandin's TED talk, I'm not so sure. The better programmers (pattern thinkers), sure, but probably not all.
    Great ted talk! :)
  12. 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.

  13. If you're going to use dreamweaver, I highly suggest only in 'code view'. It would be nice if they made a 'lite' version of dreamweaver that's only 'code view' oriented. I'll behonest though, from the many IDE's I've had, dreamweaver is probably one of the most stable. Not saying the others aren't, I was just stating. Notepad++ is a little buggy for me for some reason. I try to change the font size and sometimes it doesn't change, but when changed and saving the settings, close it, then reopen it, the settings are back to default. I update it and still get the same results.
    Only changed the color in notepad++, I use the zoom function to make things bigger. Notepad++ has had some updates lately too. :P 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.
  14. I see your point, I like that dreamweaver shows the results as your write, being a complete novice. Looking at those you mentioned i think maybe they would be more suitable at a higher level...at the same time, maybe dreamweaver could give you bad habbits. As long as i learn the right languages i think what you use will come down to trial and error. some of those programmes you suggested look like something i should look at when i learn php for sure.
    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.
  15. why so?I thought dreamweaver is essentially just a text editor? with a few tools to aid?
    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.
  16. I´m afraid I´m getting a php fobia!
    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.
  17. So, your advice is to search my questions in the php manual and read the examples there carefully?
    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:
    The format string is composed of zero or more directives: ordinary characters (excluding %) that are copied directly to the result, and conversion specifications, each of which results in fetching its own parameter. This applies to bothsprintf() and printf().Each conversion specification consists of a percent sign (%), followed by one or more of these elements, in order:
    • An optional sign specifier that forces a sign (- or +) to be used on a number. By default, only the - sign is used on a number if it's negative. This specifier forces positive numbers to have the + sign attached as well, and was added in PHP 4.3.0.
    • An optional padding specifier that says what character will be used for padding the results to the right string size. This may be a space character or a 0 (zero character). The default is to pad with spaces. An alternate padding character can be specified by prefixing it with a single quote ('). See the examples below.
    • An optional alignment specifier that says if the result should be left-justified or right-justified. The default is right-justified; a - character here will make it left-justified.
    • An optional number, a width specifier that says how many characters (minimum) this conversion should result in.
    • An optional precision specifier in the form of a period (`.') followed by an optional decimal digit string that says how many decimal digits should be displayed for floating-point numbers. When using this specifier on a string, it acts as a cutoff point, setting a maximum character limit to the string.
    • A type specifier that says what type the argument data should be treated as. Possible types:
      • % - a literal percent character. No argument is required.
      • b - the argument is treated as an integer, and presented as a binary number.
      • c - the argument is treated as an integer, and presented as the character with that ASCII value.
      • d - the argument is treated as an integer, and presented as a (signed) decimal number.
      • e - the argument is treated as scientific notation (e.g. 1.2e+2). The precision specifier stands for the number of digits after the decimal point since PHP 5.2.1. In earlier versions, it was taken as number of significant digits (one less).
      • E - like %e but uses uppercase letter (e.g. 1.2E+2).
      • u - the argument is treated as an integer, and presented as an unsigned decimal number.
      • f - the argument is treated as a float, and presented as a floating-point number (locale aware).
      • F - the argument is treated as a float, and presented as a floating-point number (non-locale aware). Available since PHP 4.3.10 and PHP 5.0.3.
      • g - shorter of %e and %f.
      • G - shorter of %E and %f.
      • o - the argument is treated as an integer, and presented as an octal number.
      • s - the argument is treated as and presented as a string.
      • x - the argument is treated as an integer and presented as a hexadecimal number (with lowercase letters).
      • X - the argument is treated as an integer and presented as a hexadecimal number (with uppercase letters).

    and this is what you asked for:
    s - the argument is treated as and presented as a string.
    This is me telling you what it is and where you can find it
    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
  18. I still have 2000 version, and that works just! the wizard i always i thought was not the brightest Gandalf in the covenant (well not in my version), i think you have to type the actual table/query name it is referring to [thistable] or [thisquery]
    ops. didn't get all:
    Action:OpenFormArguments:_session; Form; ; "[_course]=" & [ID]; Edit; Normal

  19. But then I´m still in this terrible php manual! What I´m doing: printf in Google! Not perfect, but better!
    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);

  20. It is such a long time since i did this, IF you are using a query, you could use Search within the actual field to show specific content if that's any help =["Search for Whatever"] The other option is to create drop list where you select what you are looking for, and the query reruns looking for your selection, but this involve setting up a macro, to compare to selection, and update results.
    This is the macro set by the wizard:"[_course]=" & [iD] Btw should mention what I'm using 2007 version of MS Access
×
×
  • Create New...