Jump to content

enridp

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

enridp's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi ! I'm trying to understand how php://input works. I've read the manual ( http://php.net/manual/en/wrappers.php.php ) and I have an example of a file upload receiving the file with php://input instead of $_FILES. But I can't understand it, does somebody a good tutorial about php://input ? What is the data inside it? is always the same that $HTTP_RAW_POST_DATA ? How can we send a file to PHP and receive it with php://input ? I'm trying to see what's inside php://input with this code: $in = fopen("php://input", "rb"); echo Debug::vars($in); if ($in) { while ($buff = fread($in, 4096)) { echo $buff . EOL; // fwrite($out, $buff); } } but I get always blank output (Debug is a Kohana class and it returns: Thanks !!
  2. Hi Ionisis!, I was lokking for something with Edit in Place capabilities.
  3. it was just curiosity, I was pressing F3 and I found that file (basic.php) which confused me. Thanks thorpe !
  4. Ah, OK, I was pressing F3 in Zend Studio and that take me to basic.php. Is possible to see the official PHP code for Exception Class?
  5. I didn't understand you thorpe, I'm talking about Exception class, the built in PHP class. That class is defined in basic.php, and the method is defined as: final public function getMessage () {} How can it works then? Even in php.net there's a comment at the end about that: http://www.php.net/manual/es/class.exception.php#84617 If the method has not definition why when we use ->getMessage() we get the message?
  6. Hi ! I was seeing the Exception class defined in basic.php and I found that all the methods are final and without body: final public function getMessage () {} But if I call MyCustomException->getMessage() I get the message. How does it works??
  7. The max size for max browsers's compatibility in GET parameters is near 2KB. That's enough for almost any application but the problem is that 2KB of URL is not very user friendly I guess... You can see another problem with arrays in URLs, the link in your post is not correct because the forum doesn't link all the URL. I think human readability is important too, that's why "friendly and pretty urls" exists. And a URL like this: user%5Bname%5D=Bob+Smith&user%5Bage%5D=47&user%5Bsex%5D=M& doesn't look very friendly. array in ugly urls is the fastest and easiest way, but, is it the best? I don't know
  8. Well, I was trying the URLs with brackets, and I was happy because php has two very useful functions for that: parse_str and http_build_query but with the last one we get a result like this: user%5Bname%5D=Bob+Smith&user%5Bage%5D=47&user%5Bsex%5D=M& user%5Bdob%5D=5%2F12%2F1956&pastimes%5B0%5D=golf&pastimes%5B1%5D=opera& pastimes%5B2%5D=poker&pastimes%5B3%5D=rap&children%5Bbobby%5D%5Bage%5D=12& children%5Bbobby%5D%5Bsex%5D=M&children%5Bsally%5D%5Bage%5D=8& children%5Bsally%5D%5Bsex%5D=F&flags_0=CEO It's a real pain, because the brackets ( "[ ]" ) are escaped. I was planing to "unescape" the brackets, but according to RFC 3986 and later on section "3.2.2. Host" we learn in the fourth paragraph that: So square brackets in our uri query will make it invalid. Maybe that's the reason because is not frequent to see URLs with arrays, because they are very long, agly and confusing.
  9. Yes, the problem is that I never see a URL like that, with arrays, but I see frequently the other URL style. And that make me think that maybe I'm doing something wrong. Do you know any big site with array in their URLs? Thanks!
  10. Hi ! I need to pass a lot of variables using GET, and many of them are related, so I was thinking in two options: 1) Pass them as array: example.php?categories[]=cat1&categories[]=cat2 2) Pass them in a single parameter, and split it in PHP (a custom and simpler serializer) example.php?categories=cat1|cat2 What do you think is better? (or maybe there is a 3rd option...) The second method seems more readable and short, the first easier to construct and maybe faster because we don't need to "unserialize". But I'm looking for better reasons. I'm thinking in a possible advantage of the first method over the second for SEO, because if Google is smart enough to understand that categories[] are all the same, then can understand that: example.php?categories[]=cat1&categories[]=cat2 is equal to: example.php?categories[]=cat2&categories[]=cat1 I think that is more difficult for Google to understand that with: example.php?categories=cat1|cat2 and example.php?categories=cat2|cat1 Regards!! Enrique.
  11. Hi ! I'm looking for a CMS like Unify: http://unifydemo.unitinteractive.com/unify/index.php I was seeing the demo and it looks great, you have buttons at each side of every editable content: and when you click that button you get something like this: (and the editor is content aware, is different for images for example...) The problem is tha unify is not open source, does somebody know a free CMS with live edit like Unify? Thanks !! Enrique
  12. Yes, you are right about it. But think in this situation: You have a table Addresses, and N tables that have addresses (User, Places, Events, Photos, etc) If you add addresses with Model_Address, then you need a lot of functions like: add_to_user($id_photo, $addess); add_to_events($id_photo, $addess); add_to_photo($id_photo, $addess); ... and why address should know about how that addresses are used? if we add addresses with Model_User, Model_Event, etc we have always the same method, encapsulated in the correct model. public function add_address($address){} So I see benefits in both methods, and the topic is even more complex when we see thirty part examples. I've seen frequently the schema of $user->create_post(); Maybe is not so important, and both models are equal correct without any important avantages or disadvantages over the other. Or maybe we should mix both options, when we have models like Post where the Post belongs to a User and nothing more, then Post_Model should create the posts. But if we have a situation like Addresses, where an address can belongs to multple models, then those models should create the address and not Address_Model. what do you think?
  13. And in your design of User_Model and Users_Model, who is creating a user? both? or do you have an extra model (User_Manager) for creating and deleting users? Also, I want to show you the origin of this problem: If we are adding posts with Post_Model we have this controller: $user = new Model_User($username); $post = new Model_Post; $post->add($user, $data); and if we create the post through User_Model: $user = new Model_User($username); $user->create_post($data); I think is more logical (in terms of "human") the second option, but
  14. But from your previous reply you said that Model_Post should create post, why Model_User can't create users then? Do you create a new model called User_Manager to create and delete users instead of creating them with User_Model::add?
  15. Yes, that was my first attempt, because I was thinking that if Model_User can create users, Post must create posts... (not users). But after seeing some examples and discuss it with more people most of them think that the best way is that user create the post. With this, our Model_User is not reusable (we are mixing User with Post), but if you think in terms of OO, a User has a Post, so the User is responsible for creating it, even more, in terms of "real life" the User is who creates the Post. Then I was thinking in this solution: class Model_User { public function create_post($data) { $post = new Model_Post $post->add($this->id , $data) } } Another user proposed this solution: class Model_User { // ... public function post($id = NULL) { if (isset($id)) { // we return an existing post return new Model_Post(array( "id" => $id, "user_id" => $this->id, )); } return new Model_Post->set("user_id", $this->id); } } Then you can do handy things like: new Model_User($user_id) ->post() ->add($this->request->post()); What do you think?
×
×
  • 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.