Jump to content

Mastodont

Members
  • Posts

    55
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling
  • Location
    Czech Republic

Mastodont's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. What route is best to go if I need design tables for entities with arbitrary numbers of attributes? I know that is called EAV (entity - attribute - value) and tried a Google, but missed answer for actual table design. If we have arbitrary attributes with various data types, there are three ways to go: 1. item_id - attribute - value // one table, values with different data types in third column 2. item_id - attribute - value // one table for each data type 3. item_id - attribute - string - integer - float - date ... //one column for each data type (I see this in BEA WebLogic) First option is terrible. But the others look fine (?). Downsides of second choice include complicated selects and writing, third choice leads to "Swiss cheese" table. Has anybody experiences with EAV?
  2. You do not have initialized $this->connection
  3. I vote for Toad Modeller, freeware version. Unfortunately it is no longer available for download.
  4. Then at controller I assign different variables to use at the form action url, and use empty variables to populate the form when just adding a new, and when editing i just give the variables some value. Or should I have some check there whether the variables are set, then echo them? There are many ways you can go. Try yourself. I have separate class for form processing and templates with placeholders for individual fields. These placeholders are either deleted (add form) or replaced with current values from table (edit form). small "info" things, like "Thank you for adding the news!", and I would like them to appear like in front of the "add_edit_news" view These things can be also solved by placeholders in template. You have only to track the state of the form and fill or delete placeholders. Or you can have separate messages and send them instead of form.
  5. controller asks model for some information, puts it into a variable, and sends it to a views variable Controller chooses view and view interacts with model. But controller has responsibility for updating model (adding data from form etc.) Here is nice summary: http://www.phpwact.org/pattern/model_view_controller
  6. I need to list, add and edit news. So that is 3 different views. This is one presentation view and one view with form, IMHO. So should I create each "view" a separate template file in a "news" folder for example? Yes, because you can easily edit templates this way.
  7. The Little Guy: Try to use both options: separate table "video_log" for occasional statistics with ip, date viewed, user id ... and grand total in table "video" for displaying on each request for page. if I have 20,000 videos, this would do around 40,000 queries SELECT COUNT(video_id) FROM video_log GROUP BY (video_id) - this is 1 query for select.
  8. How many people are used to play with cookies only to confuse some remote unimportant statistics? One per thousand?
  9. Yes, it is flexible. But you should use roles for better organization. The permissions would be stored in an array and only loaded on the initial login Yes, perfect. I have stored procedure for that purpose: CREATE PROCEDURE `user_login` (lUserName VARCHAR(40), lHash VARCHAR(40)) BEGIN DECLARE userID INT DEFAULT 0; SELECT id INTO userID FROM users WHERE nick=lUserName AND hash=lHash; IF (userID) THEN SELECT r.component, r.right_name, ar.type_of_access FROM rights r INNER JOIN assigned_rights ar ON (r.id = ar.id_right) WHERE ar.id_group_user IN (userID, (SELECT id_group FROM user_groups WHERE id_user = userID)); ELSE SELECT id FROM users LIMIT 0; END IF; END And permission check looks like: public function HasPermission($component, $permission) { if (isset($this->rights[$component][$permission][ā€˜dā€™]) return false; else return isset($this->rights[$component][$permission][ā€˜aā€™]); } This way you can have 'deny' and 'allow' permissions.
  10. Personally, I can't stand methods with one executable line and called only once (crumbled code). Your method setRowsToShow is IMHO also unneeded, because you can directly use constant ROWS_TO_SHOW. Otherwise it looks good, although I am surprised to see URL composed only from server_addr and page_number. (Where is component_name or subject_name or st. of that kind?)
  11. Yes, it is UML, but diagram should contain methods for CRUD and other operations, not only list of table fields.
  12. It looks like database schema, not a class diagram ...
  13. I'd rather that than throwing business logic inside my templates I don't know what you mean. Where exactly is business logic in this template for article? If I wanna present content from DB, specific names are needed. <div style="heading">{title}</div> <div style="intro">{intro}</div> <div style="content">{content}</div> nobody said you HAD to get your data into an array before passing it in to the template ... returns a 'Result' object that has methods such as nextRow .. Result object could easily implement ArrayIterator So do you prefer bunch of custom objects as other time-consuming layers instead of raw cycles? Why?
  14. Lozier did not publish all code, but it's obvious that he at first reads data from db to array - $user->get_list() - and then he iterates this array in inner template. So he does two iterations where one would suffice. Besides, his concept of caching is also simplistic, he does not consider personalization on user level - maybe is better to cache only blocks (header, menu, content, footer and so on) embedded in page template than whole page.
×
×
  • 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.