Jump to content
Larry Ullman's Book Forums


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by Edward

  1. Okay i see what you mean now so that company can have many jobs and each with baseline of 500 incrementing by one each time. That table solution seems fine. But Ah just wait, why not just put an extra column in the first table for company with job number, then you don't need a third table. bl_customer customer_ID(PK) jobNumber ... .... tbl_job job_ID customer_ID(FK) ... ....
  2. I see what you are trying to do, only one customer can have one job and you only wish to have one row on the jobs table for that, then when the customer finishes the job he will have the job number renewed. To be quite honest though i think this is ugly, i think it would just be better to fill the table with new jobs every time, that way you only need two tables. If a customer had one job not complete he would not be able to add another job until that one was completed, that's simple and you also have a history of all the jobs completed for some analysis. If i were you i would change the structure of your design a little as it makes it easier to code and the app will have more useful functionality.
  3. Well instead of making a third table, just add another column to the 2nd table, then add the job number in there separately. You could use whichever algorithm you wished to get the job number unique, higher or whatever for the other customer. Good luck with your app, yii with is controller and models and especially with its CRUD functionality makes it easy to implement those features but it does take time to get to grips with it.
  4. Yeah but looking at your tables i think you only need 2 anyway, why don't use use the job id from the 2nd table as your job number, that makes more sense to me.
  5. Well its simple you just need to get the Primary key, the ID value from the last table saved you can do this by say your model was called $modelEmployes Once you got your data saved with $modelEmployes->save(); you can get the id of that last model by referencing like this $modelEmployes->id So $modelBusiness->employ_id = $modelEmployes->id;
  6. I wanted to ask when should we use TimeStamps as apposed to DateTime's in MySQL? I read somewhere that a table should only have one TimeStamp but in some of the Larry books i found situations in where it was used twice in a table. The reason i ask this question is because i had a few tables with more than one TimeStamp in but now Yii doesn't work in updating a Timestamp and i don't know why? May be someone has a quick solution here to a supposably easy problem. You have probably seen Larry use these two situations: 1. registration_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, 2. date_updated TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
  7. Just validate and save the models that you have aquired your data in. The model relations have nothing to do with the saving of the data and are only required when you need to fetch data which you would usually do with your regular inner or outer table joins. http://www.yiiframework.com/doc/guide/1.1/en/database.ar Creating RecordTo insert a new row into a database table, we create a new instance of the corresponding AR class, set its properties associated with the table columns, and call the save() method to finish the insertion. $post=new Post;$post->title='sample post';$post->content='content for the sample post';$post->create_time=time();$post->save();
  8. Has anyone else experienced situations where widgets made for Yii don't work with dynamic data. A few times now i have started to make customizations on widgets and found in the end they are off no use and the situations need to be harded coded and customized for our own solution. Ooohhhh! I have shot myself in the foot this time. I found a work around!
  9. Let me try to explain again, how could it be a foreign key attribute if the foreign key attribute was in the other related model and the primary key was in this model. I thought your explanation meant you had to pick the key from the model you were creating relationships for only as you stated this model. You could of said this or the other model, that would make it more understandable. Again sorry i don't mean to be rude, its just i had read that more than once and got confused with it twice. I have managed to get my relationional query fetching the correct data most of it was tabular data which returned an array of objects, something i love to deal with now, so my relationships seem to be working.
  10. No offence but I found the book to be a little misleading by the way it was written on this rare occasion that is why i got into this mess. I have marked the statements below in red, you say this model which is the Comment's model in your situtation. Well what if the foreign keys are not in this model then it wouldn't always be this model. Sometimes you have the primary keys in the model you are making the relations for and foreign keys in the other. I actually never read the Yii Definitive Guide as i just read it in your book, but the way they have written it makes it clearer when they state foreign keys. So do you see how the word "this" could throw people off? Yii Book explanation: # protected/models/Comment.phppublic function relations() { return array( 'page' => array(self::BELONGS_TO, 'Page', 'page_id'), 'user' => array(self::BELONGS_TO, 'User', 'user_id'), ); } This method returns an array. Each array index is the relation’s name. The relation’s name, is a made up value, that should be obviously meaningful. Each value is another array, starting with the relationship type, followed by the related model, followed by the attribute in this model that relates to that model (i.e., the foreign key to that model’s primary key). The above code indicates that Comment belongs to Page via the page_id attribute. In other words, each com- ment belongs to a page, and the association is made through page_id. The same relationship exists with User. Yii Definitive guide explanation: Declaring relationship in AR involves overriding the relations() method of CActiveRecord. The method returns an array of relationship configurations. Each array element represents a single relationship with the following format: 'VarName'=>array('RelationType', 'ClassName', 'ForeignKey', ...additional options) where VarName is the name of the relationship; RelationType specifies the type of the relationship, which can be one of the four constants: self::BELONGS_TO, self::HAS_ONE, self::HAS_MANY and self::MANY_MANY; ClassName is the name of the AR class related to this AR class; and ForeignKey specifies the foreign key(s) involved in the relationship. Additional options can be specified at the end for each relationship (to be described later).
  11. Edward

    My Project Diary

    Larry Ullman you have been great. Your books are the best written on the market today. PHP is actually easy but it depends how it is explained to people you are very talented. I hope you will keep up your work. Also good luck on getting the yii book completed. I enjoyed reading your books on PHP especially as those have been the one's I've mostly used in my project till now.
  12. Edward

    My Project Diary

    I am still working at my project but it is taking a lot longer than expected due to many unexpected bugs and also different browser issues. Up until now I have had great success with the Yii framework which has also expanded my knowledge for Object Orientated programming.
  13. According to the relationship rules in the Yii Book i have some buggy situations? Relations for Item Model 'itemShipping' => array(self::HAS_MANY, 'ItemShipping', 'id'), (This doesn't work and returns an empty array, the thread value of the array is the relation in this model) 'itemShipping' => array(self::HAS_MANY, 'ItemShipping', 'item_id), (This works returning an array of objects using the item_id from the item_shipping table related attributed) But in the situation where 'user' => array(self::BELONGS_TO, 'User', 'user_id'), (This works using the user id from this model) So reading the Yii Book there is some subtle confusion in these relations as it doesn't work for the relationship in this model in particular cases. I think i can see what's going on, you can try testing it for yourself. Therefore, self::HAS_ONE or self::HAS_MANY = Related attribute from other model self::BELONGS_TO = Related attribute in this model Edward,
  14. I am good Antonio taken a while off to watch Wimbledon and let all the new coding knowledge i have learned sink in. I'll be starting back once Wimbledon is done. But my project is probably going to take the same time it took my brother to finish his PHD. I am hoping to get it online by 2015. Also ZenDesk is quite a good ticking system to add to your website. Okay back to the thread. Sorry
  15. Are you storing admin and regular members in the same user table? Is admin the only seller, I mean is this a shopping cart website built to sell an individual product? This should be very easy to solve with yii. One last thing, if you have users and admin in two separate tables how can you stop convergences and separate their id's. I thought it would be better keeping things simple and using one table for users, then Thomas's solution would be ideal. I will work out this for my own site in the next few days so if there isn't a solution here already I'll give you a hand.
  16. When i get the time to do it i will cover both options, cookies and the localstorage, that should be fun tabular cookies. But the thing is if there is no one on the website is so much code necessary to start of with, i found another viable solution, if someone tries to leave an important page, then just just a js alert message to warn them first before they do leave and loose there information. I think for starters something like that would be find but it also depends on the importance of the script. Last thing we want is people getting charged twice a common error which i noticed on some newly created apps. I just finished my item listing page today, it does everything that ebay does but looks and runs smoother, a hell of a lot of work involved in that. Actually attempting to write localstorage code and cookies would take a considerable amount of time with all the features the listing form covers. Hey larry, i have 300 lines in my controller alone for the item listings page, there are 1000's of lines of code includings javascript, css include files, helper classes, the models i have and about 500 lines on my views file. Seriously i think ive written more code than whats in the whole "PHP and MySQL for Dynamic Web Sites book". I apologize for going a bit off track in this thread, please forgive me i am rather excited!
  17. Yes its easier that is true, i did write about my usage of it in my project diary. Edward's revamped solution: if (localStorage) { // Use local storage. } else { // Alert message comes up "Well, what can i say, if you had an up to date browser // this wouldn't of happened, so don't even bother complaining" }
  18. I almost have blisters on my fingers already with the amount of coding i have to do. I think the ajax method sounds like a good idea, i worked with localstorage before and its a bit too static to achieve the functionality required by scripts. Have a nice weekend! Edward...
  19. "I'm so mad right now. I had written out what I thought was one of the best posts I have ever written on this forum, and when I was just about to post it" For hardcore websites like the one i am building this is a point that needs to be discussed in a little more detail. How can we save such information if the user is too make a slight error like the one you have made. The same thing happened to me when i was writing my project diary before on here, some how i had trigger the browser back button and lost my post. If you go to sites like eBay they have some mechanism to prevent things like this from happening.
  20. That's cool may come in useful for me when i get to that part.
  21. I think you are making the right decision then, yii 1 is great. But everything is taking much longer than what i expected it would with development, its definitely a good idea to use a framework. I saw some talk of making bootstrap as the main css for Yii 2 however when i use it in Yii 1 i really barely use their widget and find it better to hard code the css in. Tony Spanard was saying they shouldn't build in a css framework into Yii and it should be made as an extension, i agree with what he is saying.
  22. Thanks for your help guys! Jonathon, yes i do have CS6 but i don't have browser labs, i also read it was shutting down. http://blogs.adobe.com/browserlab/2013/03/13/browserlab-is-shutting-down-on-march-13-2013/ Are you waiting for Yii2?
  23. I will definitely report in if i find and fix weird errors, these sorts of threads are useful. I have made a major breakthrough today, finally i have all my image and manipulation/resampling sorted out. All my uploading stuff is 100% working now. Woooohooooooh Wooooohoooooh, i am extremely happy right now! Sometimes i wonder is there really a God or are we just clever, its just sometimes i am bashing away and get no where and then just in a few seconds like it all becomes clear. Oh, i do have a question. How can we test our websites with Internet Explorer on Mac, since you have one? I read a thread that Internet Explorer would no longer be produced for it, so what do we do? (My Avatar represents current website development in process)
  24. I have been working on uploading images in my Yii application everything works fine on FireFox, but in Google Chrome, when the image was uploading it was drawing up weird stuff on the page. I done further investigation and found out it was part of the appliation log. I have now disabled the application log in Yii and now image uploading is working perfectly in Yii.
  25. Yes if you take a look at my profile page you will see the ajax loader in action. I've been working a lot with these recently. The gif animation image doesn't spin on the post threads, i can see the images are being resized to prevent this. I did try to put in a 90 x 90 spinner but the page resizes anyway so no luck.
  • Create New...