Jump to content

448191

Staff Alumni
  • Posts

    3,544
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by 448191

  1. I can't make up exactly what you are aiming for. If you expect an answer, don't make people guess what the question is. A good start would be posting your current thoughts and why you are not satisfied with that, or the old schema, or something, just anything that illustrates what you are trying to do.
  2. You'll need to provide a little more specifics (specifically, code) if you want to get help. But in general, I'd say there aren't many situations where OOP "isn't needed".
  3. Should you choose to stop behaving like a spambot, you can ask me to unlock this.
  4. Please use descriptive titles without exclamation marks. One is allowed of course.
  5. Doesn't look that bad to me (FireBug edit): (of course members with special titles such as moderator, Guru, etc would not have that special title -- sorry guys) [attachment deleted by admin]
  6. 0-499 "You don't know me, but I rock" 500-1499 "Before this, I collected twinky wrappers" 1500-2999 "The disclaimer doesn't say you'll be hooked for life" 3000-4999 "My boss didn't appreciate being told to read the stickies" 5000+ "Deleting my posts causes a rift in the space/time continuum"
  7. It really doesn't get any worse than this. Locked.
  8. Actually this is only a starting point. This won't work with nested compound types, so it would get (a lot) more complicated. Not to be rude, but you don't see what that says it won't help me to explain it to you. Those three things and the second group (matching the first DomainObjectStub in the example). I should've removed the first group.
  9. I have this pattern (matching a PHP serialized string): Problem is I need to capture all occurrences (keys, datatypes and value) of the underlined groups. Right now every match overwrites the backreferences of the previous match, but wasn't there a way to avoid that? I'm having some sort of deja vu feeling about the thing. Example string: O:16:"DomainObjectStub":4:{s:21:"##0DomainObjectStub##0_id";i:1;s:14:"##0*##0_someString";s:9:"someValue";s:28:"##0DomainObjectStub##0_someFloat":0.1000000000000000055511151231257827021181583404541015625;s:12:"##0*##0_someBool";b:0;}
  10. Tempted to delete the whole thread, but staff already posted in it. Locked. If you would like to object, contact me by PM.
  11. You know what, I made a mistake. It should work as expected. If the last day of the month is the 31th, and start_date is on the 30th, it will match on the 30th. IF(30 > 29, 31 >= 30) If the last day of the month is the 30th, and start_date is on the 31th, it will match on the 30th. IF(31 > 29, 30 >= 30) If start_date is 29 or smaller, it can just match the day. Conclusion: there is nothing to fix. Yes, I'm a twat (this is where CV comes along and says "that's what I've been saying ).
  12. Same still - hits date is inaccurate when interval is in months and start_date is on the 29th, 30th or 31st of a month. If you haven't deducted it yet - it is for a daily cron. SELECT * FROM table WHERE CASE interval_measure WHEN "D" THEN MOD(DATEDIFF(NOW(), start_date), interval_amount) = 0 AND DATEDIFF(DATE_ADD(start_date, INTERVAL (interval_limit * interval_amount) DAY), NOW()) > 0 WHEN "W" THEN MOD(DATEDIFF(NOW(), start_date), (7 * interval_amount)) = 0 AND DATEDIFF(DATE_ADD(start_date, INTERVAL (7 * interval_limit * interval_amount) DAY), NOW()) > 0 WHEN "M" THEN IF(DAYOFMONTH(start_date) > 29, DAYOFMONTH(LAST_DAY(NOW())) >= DAYOFMONTH(start_date) AND MOD(MONTH(NOW()) - MONTH(start_date), interval_amount) = 0, DAYOFMONTH(NOW()) = DAYOFMONTH(start_date) AND MOD(MONTH(NOW()) - MONTH(start_date), interval_amount) = 0 ) AND DATEDIFF(DATE_ADD(start_date, INTERVAL (interval_limit * interval_amount) MONTH), NOW()) > 0 END
  13. Almost. I have to asses if one of these match today, and select only that row. Which for days, led me to this: MOD(DATEDIFF(NOW(), start_date), (interval_amount)) = 0 AND DATEDIFF(DATE_ADD(start_date, INTERVAL (interval_limit * interval_amount) DAY), NOW()) > 0 Using syntax a little closer to what you are using, it would look like this: /* Difference between today and start_date in days must be dividable by the interval */ DATEDIFF(NOW(), start_date) MOD (interval_amount)) = 0 /* Difference between today and the last day within the limit must be more than 0 days */ AND DATEDIFF(start_date + INTERVAL (interval_limit * interval_amount) DAY, NOW()) > 0 Both should accomplish the same, I think. The real issue is with months.
  14. I'm not sure I understand what you are saying.
  15. Ok, I ended up with this monstrosity.. CASE interval_measure WHEN "D" THEN MOD(DATEDIFF(NOW(), start_date), interval_amount) = 0 AND DATEDIFF(DATE_ADD(start_date, INTERVAL (interval_limit * interval_amount) DAY), NOW()) > 0 WHEN "W" THEN MOD(DATEDIFF(NOW(), start_date), (7 * interval_amount)) = 0 AND DATEDIFF(DATE_ADD(start_date, INTERVAL (7 * interval_limit * interval_amount) DAY), NOW()) > 0 WHEN "M" THEN IF(DAYOFMONTH(start_date) > 29, DAYOFMONTH(LAST_DAY(NOW())) >= DAYOFMONTH(start_date) AND MOD(MONTH(NOW()) - MONTH(start_date), interval_amount) = 0, DAYOFMONTH(NOW()) = DAYOFMONTH(start_date) AND MOD(MONTH(NOW()) - MONTH(start_date), interval_amount) = 0 ) AND DATEDIFF(DATE_ADD(start_date, INTERVAL (interval_limit * interval_amount) MONTH), NOW()) > 0 END I seems like it works fairly well (though as I mentioned it has a inaccuracy of one or two for dates after the 29th of a month), but if someone could check my logic, or suggest improvements, please. That would be very much appreciated.
  16. I guess the following should take care of the interval limit: SELECT DAYOFYEAR(DATE_ADD('2008-11-25 00:00:00', INTERVAL 2 DAY)) = DAYOFYEAR(NOW()), DATEDIFF(DATE_ADD('2008-11-25 00:00:00', INTERVAL (20 * 2) DAY), NOW()) > 0 where 20 is the limit, and 2 days is the interval. It still only matches once a year though. Edit: Now something like this works as long as the interval is in days: (DATEDIFF(NOW(), '2008-11-19 00:00:00') % 7) = 0 Now I just have to get it to work with months... Edit2: Ok, now I got this to match the month: SELECT MOD(MONTH('2009-07-25 00:00:00') - MONTH('2008-11-25 00:00:00'), 2) where the first date is the time of running (NOW()), the second date the start date, and 2 the interval. Now I just got to match the day of the month, which isn't as easy as it sounds when the day is over 29... Edit3 Okay, as a compromise I could do this: SELECT ( IF(DAYOFMONTH('2008-11-30') > 29, DAYOFMONTH(LAST_DAY(NOW())) >= DAYOFMONTH('2008-11-30'), DAYOFMONTH(NOW()) = DAYOFMONTH('2008-11-30') ) ) But that has a potential inaccuracy of 2 days...
  17. I have the following data: - a start date - a interval on which records should match (e.g. once every 7 days) - a expiration specified in intervals (e.g '2' with a interval of 7 days, query shouldn't match 14 days after the start date) I also have a column storing the interval unit (days, weeks, months). Because the interval units are constructs, I use a switch to evaluate different expressions based on the unit. E.g. WHERE CASE interval_measure WHEN "D" THEN DAYOFYEAR(DATE_ADD(start_date, INTERVAL interval_amount DAY)) = DAYOFYEAR(NOW()) WHEN "W" THEN DAYOFYEAR(DATE_ADD(start_date, INTERVAL (interval_amount * 7) DAY)) = DAYOFYEAR(NOW()) WHEN "M" THEN DAYOFYEAR(DATE_ADD(start_date, INTERVAL interval_amount MONTH)) = DAYOFYEAR(NOW()) WHEN "Y" THEN DAYOFYEAR(DATE_ADD(start_date, INTERVAL (interval_amount * 12) MONTH)) = DAYOFYEAR(NOW()) END The above only matches once a year, what I need is to match every interval. This also doesn't account for the expiration after which records shouldn't be matched. Any help very much appreciated.
  18. If you want to ensure child classes implement a common method, but not expose it outside the hierarchy, use an abstract protected method.
  19. All methods in an interface must be public. It wouldn't much of an interface otherwise, would it (stop and think for a sec)?
  20. Honestly, I could care less. Actually, I think it is a better choice than the double semicolon, aesthetics aside. Just makes the whole thing less likely to be ambiguous. I don't care much either way. But do it already.
  21. It feels like I have been waiting for a stable php 5.3 release for ages! The index of php.net says the stable should be released "between mid September and mid October of 2008"... It's almost December for crying out loud. The todo list for 5.3 states alpha3 for "around early November"... Yet, only one of the 24 todo items has been completed. Stop slacking and get it done! We want namespaces!
  22. That's Flyweight, not Lazy Init. Combined you could do something like this: 1. Date (and the like) is a Value Object You can't change the internal value. If you use a modifying method (ie add(Date $date)), you get a new object. The Value Objects use a Factory. 2. The Factories use a Registry (or just a basic hash table -- slightly more efficient) This allows reuse of objects that are identical by Value Object standards. 3. Your database access package features a ResultSet wrapper class, employing Lazy Init. It's just your basic wrapper class, that uses the same Value Object Factories when an item in the ResultSet is requested. This class is a good candidate for the SPL Iterator family and the magic methods.
×
×
  • 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.