Jump to content

koen

Members
  • Posts

    47
  • Joined

  • Last visited

    Never

Everything posted by koen

  1. I've read the section and tried some things. But I don't see how full text search can match a partial word. To give another example: the field contains 1 word for every row row1: possibl row2: possib I want the best match when I search for 'possible' (wich is the field from row 1).
  2. Example: searching for string ABCDEFG, and in DB there's string ABCDE and ABC. ABCDE is best match. What sql can I use for this? One option I see but don't really like is searching with WHERE string LIKE abcdefg OR string LIKE abcdef OR ...
  3. This category class asks the connection upon construction. I would wait with this until necessary. A $this->getConnection() method could do this.
  4. I think we'll get scenario's as described above. Hosts who have enabled the mysql/mysqli extension and aren't going to enable extra extensions for working with pdo.
  5. Is there any indication that if they push PDO to be the standard the mysqli drivers for it will be enabled by default?
  6. You may want to declare a private __clone() method to the singleton too.
  7. Another option is the one used by CakePHP. I only very briefly looked at it but it doesn't seem to require anything other than the files itself.
  8. There's an interesting discussion going on right now about the MVC models in PHP frameworks, and about the nature of the MVC model itself. I think the email quoted in the following post is an interesting clarification of some widely misunderstood MVC conceptions: http://pookey.co.uk/blog/archives/43-phplondon08-the-crazy-guy-mail.html
  9. Suppose you're working in a database class and every method in this class needs the database connection. A common solution is to to use somethink like this private $db; public method getPosts() { $db = $this->getConnection(); $db->execute( // some sql here); } private method getConnection() { if (is_null($this->db) $this->db = // stuff to get connection return $this->db; } This doesn't prevent methods from calling $this->db directly. Encapsulation is mostly viewed between objects but not in the object itself. To prevent methods from accessing $this->db a solution would be the following: private method getConnection() { static $db; if (is_null($db) $db = // stuff to get connection return $db; } Is there a reason the first one is used and not the second one?
  10. That would mean I'd try to log in your account and after a number of failed attempts you and I are both blocked from loggin in? I'd say only block the visitor who's trying to log in.
  11. Is there any technique that prevents the view from updating the model? Example: Controller says: model, do a login with credentials x and y. The view has access to the model also, to display some data. But I don't want it to be able to ask it to do a login. So I think the question is whether there is a way to allow the controller to access [property or method] X of the model but not Y, and the view only Y but not X.
  12. http://www.martinfowler.com/eaaDev/uiArchs.html
  13. So you have a couple of checkboxes on the first page that each hold an array,eg array(2, 5, 7) for checkbox 2. Then on the second page, after a user has chosen checkbox 2, you want a button for each of these values in the array. Is that what you want?
  14. One day you have 2 session handling classes, one with a DB, and with the regular session mechanisms, and you want to be able to choose between the dynamically. If you get your session class from the factory, there's only one place to get the session, which also decides which of the 2 session handlers will be used. What would be a good design now to include possible changes like this?
  15. I don't see a form with action=add?
  16. I've also learned from the way joomla did things and their take on the registry is something I like. Previously I have singletons all over the place, now I use a factory as a central point for getting singletons and object creation logic (like a 'real' factory). I haven't run into any unwanted side effects yet. But I have to admit I sometimes also have the feeling I'm overlooking something. So I'm curious what others think of this too.
  17. $pairs['$value'] = $name; I think that should be: $pairs[$value] = $name;
  18. You load "yoururl.com/index.php" and then determine what other page to include. So index.php gets loaded by default, and then, depending on the value of your input variables, you include another page in that page. I guess what you need would be index.php have the contents of pages.php and a the contents of index.php in a included page like index_include.php.
  19. The best thing I've found to avoid spaghetti code is to use a MVC pattern and adhere to it. GOTO 3
  20. A possible implementation could be a field 'active' in the user table. On a regular basis you delete all users where active=0 and the time is more than 10 days from now.
  21. A possibility is to demand an author for every area under control (auc). Eg: interface auc_interface { function getComponentID() {} function getAuthor() {} } Then the acl can check if the author is the same as the user the acl was created for and if there's a match the 'self' role comes in to play. A rule like $acl -> allow('self', 'profile', 'edit') would then make sense. The only thing that's a bit awkward is to have an author for every auc.
  22. There's one thing I can't fit in a role based system: the owner of a domain/resource/object/whatever-name-for-the-area-under-control. Normally you'd assign a role or roles to a user, then somewhere in your code you ask the ACL system whether the user can do X on Y. Eg $acl -> userAllowed('edit', 'post'). But what about things where a role doesn't really fit, eg a profile. Every user has a profile, and only the user that owns the profile can modify it (or the administrator and optionally some roles). Clearly you can't set a rule like $acl -> allow('registered_users', 'edit', profile). That would many any registered user can edit the profile of any other registered user. Also a rule like $acl -> allow('userID25', 'edit', 'profile25') would't really be practical. Ideally you'd have a rule like $acl -> allow('self', 'edit', 'profile'). But how could that be implemented (in the DB and asking for authorization with userAllowed())?
  23. What about: echo ">{$location_data["menu_name"]}</option>";
  24. This is not really a php problem, but you have to set the button/form action not to the page that contains the iframe, but to the framed page.
  25. I guess that's the way I would prefer to implement it. Eg in the registry class making the $input private and creating a method for setting and getting the input values. I don't think scattered calls on the registry are bad smell in this case. There would be scattered calls to whatever class/method is used to get the input data. So, if the calls to the registry became more complex, it would be better to have something in between these callers and the registry, is that what you are trying to say?
×
×
  • 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.