Jump to content
Larry Ullman's Book Forums

Edward

Members
  • Posts

    1115
  • Joined

  • Last visited

  • Days Won

    27

Everything posted by Edward

  1. Thanks that did the trick Larry i didn't see the sudo command written in the terminal manual i was reading. Okay like you said in your manual the script did through some extra errors while trying to load the time zones, here is what i got: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2) I fixed this by editing: tmp/mysql/my.cnf (Set my password in here) (It is also worth noting that the mysql server must be turned on for the time zones to install) So after the edit and this command was entered at terminal ./mysql_tzinfo_to_sql /usr/share/zoneinfo | ./mysql -p -u root mysql The time zones were successfully installed, well most of them... Warning: Unable to load '/usr/share/zoneinfo/Asia/Riyadh87' as time zone. Skipping it. Warning: Unable to load '/usr/share/zoneinfo/Asia/Riyadh88' as time zone. Skipping it. Warning: Unable to load '/usr/share/zoneinfo/Asia/Riyadh89' as time zone. Skipping it. Warning: Unable to load '/usr/share/zoneinfo/Mideast/Riyadh87' as time zone. Skipping it. Warning: Unable to load '/usr/share/zoneinfo/Mideast/Riyadh88' as time zone. Skipping it. Warning: Unable to load '/usr/share/zoneinfo/Mideast/Riyadh89' as time zone. Skipping it. Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it. Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it. OMG! I have 579 time zones in my database now, that's about 10 times more than i expected. HartleySan: I was only planning on using SSL on certain scripts of the site, SSH is not something i looked into. Thanks
  2. I have been bumming around with Mysql timezones all day and got no where. I found your well written article Larry in the last hour http://www.larryullman.com/2011/05/27/utc-and-time-zone-support-in-mysql/ I got this problem like you said Warning: Unable to load ‘/usr/share/zoneinfo/+VERSION’ as time zone. Skipping it. But the trouble is when I tired to delete the file or make a new folder to add it into i got permission denied. I was also unable to even find this hidden usr folder. I can see all the time zones are there. -rw-r--r-- 1 root wheel 6 Jul 22 20:52 +VERSION drwxr-xr-x 68 root wheel 2312 Jul 22 20:54 . drwxr-xr-x 47 root wheel 1598 Nov 16 2012 .. drwxr-xr-x 56 root wheel 1904 Jul 22 20:54 Africa drwxr-xr-x 144 root wheel 4896 Jul 22 20:54 America drwxr-xr-x 13 root wheel 442 Jul 22 20:54 Antarctica drwxr-xr-x 3 root wheel 102 Aug 24 2012 Arctic drwxr-xr-x 96 root wheel 3264 Jul 22 20:54 Asia drwxr-xr-x 14 root wheel 476 Jul 22 20:54 Atlantic drwxr-xr-x 25 root wheel 850 Aug 24 2012 Australia drwxr-xr-x 6 root wheel 204 Aug 24 2012 Brazil -rw-r--r-- 1 root wheel 765 Nov 16 2012 CET -rw-r--r-- 1 root wheel 837 Nov 16 2012 CST6CDT drwxr-xr-x 11 root wheel 374 Aug 24 2012 Canada drwxr-xr-x 4 root wheel 136 Jul 22 20:54 Chile -rw-r--r-- 1 root wheel 871 Apr 29 01:12 Cuba -rw-r--r-- 1 root wheel 679 Nov 16 2012 EET -rw-r--r-- 1 root wheel 56 Nov 16 2012 EST -rw-r--r-- 1 root wheel 837 Nov 16 2012 EST5EDT -rw-r--r-- 1 root wheel 695 Nov 16 2012 Egypt -rw-r--r-- 1 root wheel 1285 Nov 16 2012 Eire drwxr-xr-x 37 root wheel 1258 Aug 24 2012 Etc drwxr-xr-x 61 root wheel 2074 Jul 22 20:54 Europe -rw-r--r-- 1 root wheel 101 Nov 16 2012 Factory -rw-r--r-- 1 root wheel 1323 Nov 16 2012 GB -rw-r--r-- 1 root wheel 1323 Nov 16 2012 GB-Eire -rw-r--r-- 1 root wheel 56 Nov 16 2012 GMT -rw-r--r-- 1 root wheel 56 Nov 16 2012 GMT+0 -rw-r--r-- 1 root wheel 56 Nov 16 2012 GMT-0 -rw-r--r-- 1 root wheel 56 Nov 16 2012 GMT0 -rw-r--r-- 1 root wheel 56 Nov 16 2012 Greenwich -rw-r--r-- 1 root wheel 56 Nov 16 2012 HST -rw-r--r-- 1 root wheel 438 Jul 22 20:52 Hongkong -rw-r--r-- 1 root wheel 429 Nov 16 2012 Iceland drwxr-xr-x 13 root wheel 442 Aug 24 2012 Indian -rw-r--r-- 1 root wheel 610 Nov 16 2012 Iran -rw-r--r-- 1 root wheel 803 Apr 29 01:12 Israel -rw-r--r-- 1 root wheel 185 Nov 16 2012 Jamaica -rw-r--r-- 1 root wheel 125 Nov 16 2012 Japan -rw-r--r-- 1 root wheel 87 Nov 16 2012 Kwajalein -rw-r--r-- 1 root wheel 493 Apr 29 01:12 Libya -rw-r--r-- 1 root wheel 765 Nov 16 2012 MET -rw-r--r-- 1 root wheel 56 Nov 16 2012 MST -rw-r--r-- 1 root wheel 837 Nov 16 2012 MST7MDT drwxr-xr-x 5 root wheel 170 Aug 24 2012 Mexico drwxr-xr-x 5 root wheel 170 Aug 24 2012 Mideast -rw-r--r-- 1 root wheel 882 Nov 16 2012 NZ -rw-r--r-- 1 root wheel 732 Nov 16 2012 NZ-CHAT -rw-r--r-- 1 root wheel 877 Nov 16 2012 Navajo -rw-r--r-- 1 root wheel 165 Jul 22 20:52 PRC -rw-r--r-- 1 root wheel 837 Nov 16 2012 PST8PDT drwxr-xr-x 44 root wheel 1496 Jul 22 20:54 Pacific -rw-r--r-- 1 root wheel 981 Nov 16 2012 Poland -rw-r--r-- 1 root wheel 1264 Nov 16 2012 Portugal -rw-r--r-- 1 root wheel 268 Nov 16 2012 ROC -rw-r--r-- 1 root wheel 152 Nov 16 2012 ROK -rw-r--r-- 1 root wheel 171 Nov 16 2012 Singapore -rw-r--r-- 1 root wheel 993 Nov 16 2012 Turkey -rw-r--r-- 1 root wheel 56 Nov 16 2012 UCT drwxr-xr-x 14 root wheel 476 Nov 16 2012 US -rw-r--r-- 1 root wheel 56 Nov 16 2012 UTC -rw-r--r-- 1 root wheel 56 Nov 16 2012 Universal -rw-r--r-- 1 root wheel 558 Nov 16 2012 W-SU -rw-r--r-- 1 root wheel 679 Nov 16 2012 WET -rw-r--r-- 1 root wheel 56 Nov 16 2012 Zulu -rw-r--r-- 1 root wheel 4326 Nov 16 2012 iso3166.tab -rw-r--r-- 1 root wheel 1267 Nov 16 2012 posixrules -rw-r--r-- 1 root wheel 20066 Jul 22 20:52 zone.tab rm +VERSION override rw-r--r-- root/wheel compressed for +VERSION? Y rm: +VERSION: Permission denied
  3. Okay, and what do you mean by Kardais? Oh sorry i apologize kardais the members name sorry.
  4. Actually i could of use strings and concatenation but now i remember why i did the array because first i used comma's between the times so 4 Years, 2 Months, 1 Day, so for that method it was difficult without the array. Later i changed my mind and decided to use spaces. I could change it back to strings but actually i prefer the array method now that its done, it doesn't really matter. The thing is there are so many parts of code nothing can be completely perfect so i will make do with that.
  5. I did orginally start with a string but you see what if we have 0 Years, 0 Months etc, i don't want to write that out on the screen, so therefore i just just and array then imploded the implements that were created. If you code it via a string and concatenation it takes a lot more code and you have to set variables to null and flags and stuff. The above code did the trick much easier. Love you oop code also its really cool, now i have loads going on everywhere so i guess later i will need to make some good classes, ha once i find out what is going on? hehe I have used exceptions in other parts of my code but not for this part, i guess when i give the site the run live i will see what happens, if i get stuff coming up in the error log or people filling out the bug report form ill go back and fix them. Looking forward to seeing what will happen when my site goes live. Oh, i wish i could of had blue eye's everyone has dark eyes, nothing special these days. I am working on a countdown timer right now, just like the one on ebid.net, check it out on this page. http://as.ebid.net/for-sale/vodafone-huawei-ascend-g300-pay-as-you-go-smartphone-111862013.htm One thing i am wondering is how often should i call stuff a function with js every half second? I am wondering what sort of impact this is going to have on the overall performance of the website. Hehe Larry, anything I want to code, anything, i can get it done now!
  6. You have to add to the rules() array in the model where you have the attribute that you need to change the default error message array('title','required', 'message'=>'Enter a title for your item!'), in the array message is they key and the value attribute is 'Enter a title for your item!'; So if you have a title attribute as in the above, you have to add message in as another parameter in the array. Its as simple as that or am i missing something?
  7. You have made a cool resuable class, i can see you are further with your project than i am, probably as you knew CI when i was learning Yii. At the moment i only need this function in one model but if get it occuring in repeated area's i was going to make it part of a helper class. I currently only have a Image Manipulation Helper Class. Here is my code: /** * Get the time user has been a member for in the format years, months, days * @return string of the time */ public function getMemberTime() { $d1 = new DateTime($this->registration_date); $d2 = new DateTime(); $dateIntervalObj = $d2->diff($d1); $memberTimeArray = array(); if($dateIntervalObj->y > 0) $memberTimeArray[] = ($dateIntervalObj->y == 1) ? '1 Year' : $dateIntervalObj->y.' Years'; if($dateIntervalObj->m > 0) $memberTimeArray[] = ($dateIntervalObj->m == 1) ? '1 Month' : $dateIntervalObj->m.' Months'; $memberTimeArray[] = ($dateIntervalObj->d <= 1) ? '1 Day' : $dateIntervalObj->d.' Days'; return implode(' ',$memberTimeArray); } I haven't taken into account errors and exceptions as there will definetely be a datetime value and timestamp in the model otherwise we wouldn't get this far on my site. I saw your website link from there its pretty cool, you and your friends look similar to people in my family. I don't know what happened to me my Dad has blond hair and blue eye's and i got Dark Brown hair and eye's. I turned out to be the Hell Boy Hey ive just realized you have the same sort of bug that is on my site, the page shifts left, now i see why because of the vertical scroll bar appearing on the right on Mozilla FireFox. I thought it was a CSS issue and overlooked the scroller.
  8. Just want to say thanks very much, i managed to create a difference time function that returned the format "2 Years 4 Months 2 Days". I found some horrible solutions for this online. The DateTimeInterval Object created from Datetime has certainly done me the trick. That's why i don't call you Dr. Thomas for nothing, thanks Antonio. (PS. I won't call you that anymore, sorry Antonio)
  9. After some peaceful mediation: '<controller:item>/<id:\S+>'=>'item/view', As you can see this will strictly work for only the item controller and will not interfere with others. I also used \S because this means not whitespace, if I use /w it will cover all word characters but not the hypen "-" which I need. You also need to add pages in item you need to access in config/main.php routes otherwise the above route will always send you to the view page. 'item/create'=>'item/create', Have a nice weekend everybody!
  10. I have a slight problem I want to be able to load items via name or numerical id, yii is already set to work with numerical id through '<controller:\w+>/<id:\d+>'=>'<controller>/view' but what if i pass a unique string instead to the view page how could i get that to work for example: mywebsite/item/babolat-aerodrive-2013-nadal-rafa-3 I have tried to make some of my own customizations but they have failed to work and i received the following error message: Error 404The system is unable to find the requested action "babolat-aerodrive-2013-nadal-rafa-3". Is there someone that may know how to deal with such a situation?
  11. I heard many of you here complaining about php.net check out their site now they have now improved the user interface and features go in and take a look. I myself have always like php.net its a site by looking at i know i can trust, i just love checking out exactly how things work return values for functions etc etc.
  12. Okay i see the importance of TIMESTAMP NOW, http://stackoverflow.com/questions/409286/datetime-vs-timestamp Very Important Point "In MYSQL 5 and above, TIMESTAMP values are converted from the current time zone to UTC for storage, and converted back from UTC to the current time zone for retrieval. (This occurs only for the TIMESTAMP data type, and not for other types such as DATETIME.)" mysql> show variables like '%time_zone%'; +------------------+---------------------+ | Variable_name | Value | +------------------+---------------------+ | system_time_zone | India Standard Time | | time_zone | Asia/Calcutta | +------------------+---------------------+ mysql> create table datedemo( -> mydatetime datetime, -> mytimestamp timestamp -> ); mysql> insert into datedemo values ((now()),(now())); mysql> select * from datedemo; +---------------------+---------------------+ | mydatetime | mytimestamp | +---------------------+---------------------+ | 2011-08-21 14:11:09 | 2011-08-21 14:11:09 | +---------------------+---------------------+ mysql> set time_zone="america/new_york"; mysql> select * from datedemo; +---------------------+---------------------+ | mydatetime | mytimestamp | +---------------------+---------------------+ | 2011-08-21 14:11:09 | 2011-08-21 04:41:09 | +---------------------+---------------------+ The above examples shows that how TIMESTAMP date type changed the values after changing the time-zone to 'america/new_york' where DATETIMEis unchanged. Well this is the time for me to find that good old famous book, "PHP and MySQL for Dynamic Websites and check out UTC time zones. Thanks Antonio and Larry i will be able to work out the rest on my own.
  13. Antonio with your databases do you use timestamps or only datetime's? Do you see a reason why we need to use a timestamp other than datetime. I am the kind of person that likes to see consistency with my work so this situation for me is still not clear.
  14. After running further tests i was able to get the records to update in the database I used this in Model Rules() array('date_updated', 'default', 'value'=>new CDbExpression('NOW()'), 'on'=>'update'), I just want to point out that it did not work for: date_created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, date_updated TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', but it did work for: date_created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, date_updated TIMESTAMP NULL, or date_created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, date_updated DATETIME NULL,
  15. Thanks but with regards to Yii am already aware with the functionality where and when to do things without that knowledge i would not be as far as i am now. I was just curious for the timestamp only, sometimes you write more than you need to but thanks anyway. Also with a function like yours in model classes would not be suitable for storing the method as it would be required from many of the models especially in my site, so a helper class would be more appropriate storage. With regards to code there are also things for myself which i think are easy but i land up spending a lot more time on. Or there are solutions online which i have used and then later found to be not complete so they have to be recoded. Its difficult to be perfect and especially to understand what someone else is doing. Thanks for your answer and please be positive i meant no offence to you.
  16. Okay Larry i was checking in your javascript book in the final chapter. In your items table you use dateOpened timestamp NOT NULL, dateClosed datetime NOT NULL, What is your reason for using timestamp for one column as apposed to just using datetime for both table attributes?
  17. I wasn't giving you any attitude, i am actually in a good mood here, its just you stated something so i wanted to know how you would do that, as i will need to make the TimeStamp format also, just wanted to see your solution that's all. I was highly applauding you as i even called you Dr.Thomas. Please give me your solution i would appreciate it.
  18. Well its a problem that is taking your more than 15mins to solve from now, haha. Okay ill see you later i need to get onto my project.
  19. Oh and by the way Dr.Thomas, have you found that you can hardcode stuff in a few places first before you later create helper class functions. Or you may have some model methods that are similar and then just decide to cut those out and later replace with one helper class function. It seems to me that those models and so can be like some drawers in your room and you change the items about in them to find the best order. I don't think its really possible to plan for the larger projects unless you have a lot of experience and then again its probably not possible to get it perfectly correct.
  20. If you haven't purchased the Yii Book already i would advise you to do so and spend sometime reading it. I like to help but i can't be there to hold your hand through your whole project, i have my own work you know. Yii can be quite a challenge to start of with but after reading a few chapters of Larry's book you will be able to hit that wall you were speaking of like a BombShell.
  21. Show me how you would do that? There are many people online with answers for this but i just want to see how you will resolve this?
  22. I am aware of all of those things but sometimes we need timestamps. You can even add your own behaviours with timestamp rules did you know about that?
  23. Thanks for your good answer Larry! Yes you are correct Yii doesn't update timestamp columns automatically but i had added my own rules for this to the models which failed to update. I did plan stuff out for my project before started but i have had to make unexpected changes anyway. The trouble is right now i am also not sure whether i will need timestamps or not with certain things as i am aware a lot of the time functions require this format. On the otherhand there are other time functions which i need which php doesn't provide.
  24. Otherwise if you do this with three tables you will need to do the following: $modelCustomer = Customer::model()->with('jobNos')->findByPk($customerID); $modelCustomer->jobNos->jobNumber++; $modelCustomer->saveAttributes(array('jobNumber'));
  25. So if you wanted to get the jobNumber from customer and increment by one you would do this. $modelCustomer = Customer::model()->findByPk($customerID); $modelCustomer->jobNumber++; $modelCustomer->saveAttributes(array('jobNumber'));
×
×
  • Create New...