Jump to content

paralyzah

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Everything posted by paralyzah

  1. If you're asking how to get and sort the data, I'd be using two queries. One to get all the regular events and one to get the recurring events. Then I'd have to convert the recurring events to actual dates for a specific time frame (i.e. from now and three months forward in time). Finally I'd store all the dates in one array and sort them.
  2. What your asking for is exactly what I answered in my previous post!? You'll need the two tables I gave you in addition to the table where you store the regular events.
  3. RecurringEvents: Key, Pattern, Date RecurringEventsExceptions: ForeignKey, Date In RecurringEvents, Pattern is a TINYINT where 1 = Weekly, 2 = Every second week, 3 Monthly Date is if Pattern is 1 or 2 the day of the week, and if Pattern is 3 the day of the month. In RecurringEventsExceptions, Date is an excact date that match a recurring event and means that the user have moved it (and you've stored it as a regular event this week or month or whatever) or that the user has deleted it this week or month or whatever. You'd probably need some other fields in the tables for other purposes, but these are the ones you asked for.
  4. To be honest, I haven't read my self up on what PDO is or does, so to me it's basically a buzz word. And that's kinda why I'm asking. I thought maybe there would be any benefits using PDO? And that if I were to use it, the best way to use it in an existing application (built with my framework) would be to create a new adapter using the same interface as my other adapters? If I were to create a new adapter using the same interface as my other adapters, I wouldn't need to redesign anything. I was just asking if there would be a better way to implement PDO. But as I said, I'm totally blank regarding anything PDO. However, what I was really asking (or trying to ask) was if this is the way to write the data abstraction layer, and if this is it? Or should there be more to it? Or are there other ways, and maybe better ways to do it? And sorry for asking, because it may come as a stupid question, but what's a business object? Is it what I called a getter and setter class?
  5. Hi, I'm looking for the best way to design the data abstraction layer of my application. The application is using the MVC design, so this'll be the model. Here's what I have so far. I'd like some pros and cons, and maybe alternative solutions. At the bottom I have an adapter. Actually I only have one (MySQL, using the standard MySQL extension) and a half (SQLite, using the standard SQLite extension) so far. I'm going to need MSSQL too in the near future. The adapter is fabricated by a factory method like this: $Connection = Connection::factory("mysql://user:password@host:port/database"); It has basic methods like query(), escape(), getInsertKey() and so on. In addition I have an extended version of each adapter which has methods like getDatabases(), getTables(), createTable(), renameTable() and so on. So this is the adapter. On top of the adapter i build getter and setter classes which i guess you could say is the actual models (the adapters are part of the framework). I have two classes for most tables. One representing the entire table and one representing one specific record. Heres an example: $Users = new Users ( $Connection ); $Users->create()->set( "Email", "user@domain.org" )->set( "Nickname", "paralyzah" )->update(); The second line may be confusing. Most methods in the record class return itself. So, what's happening here is I create a new object representing the entire table. I create a new record, which is not actually created in the database yet. I set some values of some fields. And last, I update it. Now it's created in the database. Since this is a new record, the update method will figure out that and use INSERT instead of UPDATE. The point is anyway that I have two classes for most tables, and they are merely getter and setter classes that takes care of the SQL statements needed. Here's a specific question: In the setter methods, I validate the data. i.e. If it's a string I escape it (to prevent SQL injection) and if it's an email this is the place I make sure that it is. If the data doesn't validate, an exception is thrown, so I can handle that some place else. Is it a good or a bad idea to do this kind of validation here? This is basically it for the data abstraction layer. Above this, I'm in the business logic layer. Here I may have other classes that do business logic related to users (or whatever). i.e. I usually have a method like hasAccess() which determines whether a user has access to a specific area (or unit of code to be correct): if ( $SignedInUser->hasAccess( 2 ) ) { // 2 is the key for the access area. // Access granted. } else { // Access denied. } What other ways are the to solve this? If I were to use PDO, would that be just another adapter or would it be wise to follow a totally different design pattern? Thanks in advance guys! Hope this sparks a great debate!
  6. You cannot have a field containing keywords. Any database field should only hold one piece of information. Keywords are many pieces of information. Your database should have two tables and look something like this: Sites: Key, URL, Name, Info Keywords: ForeignKey, Keyword
×
×
  • 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.