Jump to content
Larry Ullman's Book Forums

Antonio Conte

Members
  • Posts

    1084
  • Joined

  • Last visited

  • Days Won

    126

Everything posted by Antonio Conte

  1. It should probably be C:\xampp\htdocs\SomeYIIAPP. (Where the last part is the folder you installed YII to) Have you installed YII using the command line yet? Yii needs to be installed, so if you haven't done that yet you can't find it using your browser. The book teaches you how to do this step by step. Let's say it's in the folder exemplified. The URL would then be http://localhost/SomeYIIApp/. Localhost starts looking into the htdocs folder found inside xampp.
  2. It depends where you install the application inside the htdocs/sites folder.
  3. All models can derive from a base model too. If you have repeated code, consider creating a baseModel for this purpose. The default controller does not make sense for validation, but you may utilize the base model there. (using the model's validate method.)
  4. Glad it worked. Note that you probably only have to apply it to $messages['message']; and that you should apply htmlentities() non-the-less. Theoretically, I could insert an iframe in a post or as a username, and overlay your entire website with a malicious website now. Read up on XSS. strip_tags() should be applied to pretty much everything you get from the users that should be displayed again. It's a prevention you should apply before the site goes live. If this is for learning purposes, take note of XSS (Cross-site scripting) and read or ask about it the next time you build something that's going live.
  5. No problem, Matt. Did you solve the problem now? I noticed the past tense in your last post just now. I'm not fluent in english, so I miss some important points sometimes. If not, you seeked confirmation, right? Btw. I used the exact same approach on a project in CodeIgniter, except I added an admin model and methods with dynamic binding to the company foreign key. (Using dropdowns in the Admin UI) That way, you can operate as a company on their behalf. Just an idea for you. Another idea is roles for users, as some users might need access to payment info/similar limited company info. Hit me up if you find a solution to a tricky problem or need suggestions for anything. The project is still in development untill the summer.
  6. Search on this forum. This is a pretty common problem. You need to add some config for the mail function to work.
  7. null makes the most sense for me. Some detective works shows me that the join type used with AR is a LEFT OUTER. That's good news for you. Add a belongs_to relationship in the user model linked to the company. That should do the job. (Unless I've understood anything wrong.)
  8. The CSS file path will be relative to the script if you don't use a absolute path. You can check out the base path HTML structure or consider defining an absolute path. The absolute path will be the full path on your operating system. (Probably starting at your harddrive c:\ )
  9. The script cannot find the path you specify. Play around some more, and find the correct path.
  10. If you are familar with the command line, consider enabling PHP and Apache on your operating system. Mac OSX comes pre-install with PHP,and Apache, and you only need to enable those to have a local server. It's a pretty simple process. A quick google search should give you a 5 to 10-step tutorial. If not.. Consider MAMP.
  11. Two-sided issue here. One side is saving, the other is displaying. 1. When you save a new post, it looks like it will use line breaks for that. You need to change that to HTML break tags if you intend to save the posts formated. If you want that, be sure to do some research. Allowing users to save HTML can introduce problems such as Javascript in the code. Because of that, considering looking at Wysiwag-editors or BBcode with server-side validation of tags/code. If HTML is not wanted, then you still need to use strip_tags() / htmlentities() /similar to prevent users to add bad code. 2. When you display a posts, you need to change fro new lines to break tags. (If not done in step one) That means, when you echo out $body, the nl2br() function should be applied.
  12. NetBeans, Eclipse, (My personal favorite) PHPStorm (Not free - but seriously good) and probably a few more good out there. Notepad++ is a good tool, but it's to simple for serious development in my mind. When you discover projects, (Organization of files) code hinting, error highlightning, automatic code generation, Git integration, FTP integration and lots of other cool stuff, it will blow your mind. However, if you don't like those features, it'll still function as a better text editor than Notepad. Using functionality is obviously optional. Both NetBeans, Eclipse and PHPStorm are available for both PC and Mac.
  13. This is a many-to-many relationship (I take it for granted a User can have several Companies - more on that later). Normally, you'd have to write a CompanyUserModel, but fortunatly, YII has built in support for this. The relations() method here should be placed on the User side, and look as follows (approximatly): return array( 'company' => array(self::MANY_MANY, 'User', 'comanpy_user(user_id, company_id)') ) If a User can only belong to one Company, I would normalize the table differently. Add the foreign key to the user table, and use a normal outer join.
  14. Do you have the structure to show us? Would make it easier to understand what you want to achieve.
  15. It might be as simple as using the nl2br() function on the input. It stands for new line to break. (\n to <br />) http://php.net/manual/en/function.nl2br.php
  16. Do a few google searches. I'm sure you'll find good hosting located in your general area.
  17. Ah. I did not pick up on that. I see now that the class definition is in uppercase while the object initiation is camel case. Sorry about that, Jaepee. You are correct. gmgj: You need to change the class definition. Secondly, you should change the visibility on your properties and use setters and getters instead. That's the principle of encapsulation.
  18. Edit. Yes, he needs to change either the definition or the initiation. I think the former makes more sense.
  19. Several ways. 1. Cast an exception. This is probably the best solution. If you can't open the connection, that break application crucial functionality. That's worthy of an exception in my mind. Objects that has errors (real errors) should not be created. That's an important principle. 2. Create a standalone setter and force a call to that instead. You already have this, but you change it's modifier to public instead. That way, you can easily check the result of the method. This method should return an exception if errors occur non-the-less, so I suggest number one instead. This solution might be viable if you find ways to possibly find a solution, like checking several URLs and that sort of things. In my mind, this seems like an exception case. If it's not valid, it's an exceptional state and should not work. If it breaks main functionality, always trow exceptions.
  20. Build you array differently. Store it to a key "records" (or similar) then bind the title the same way. That way, you can echo $title and foreach $records without any problems. If your problem is re-iteration, there's several ways to do that. The easiest way might be calling reset() on $data['records']. (Considering how my keys are arranged.)
  21. I've not done something like this in YII, but doesn't it make more sense to do this in the view file? Both the user links and the PM links can be done that way. Considering the class is static, this makes more sense to me. The views looks a bit uglier, but they also make more sense. Not to insult you, but you would of course need to change the $messages array bindings for this to work. Just an easy miss... <?php foreach($messages as $message) : ?> <tr class="warning"> <td><?=CHtml::link($sender_username, Yii::app()->createUrl('$sender_username'));?></td> <td><i class="<?=$message['icon'];?>"></i></td> <td><?=CHtml::link($item_title, Yii::app()->createUrl('$item_title'));?></td> <td><?=$message['date'];?></td> </tr> <?php endforeach; ?> Same with the icon. Place the HTML where it should be. The class name is enough to change the icon if you should ever need it. If not, do that fully in HTML.
  22. Xampp works perfectly on Mac too, but you should no that OSX has PHP installed already. It just needs to be turned of an possibly configured a bit. It's a pretty simple operation, really. Do a quick google search, and your good to go.
  23. C is an older language that has influenced a lot of languages, including C++, C# (Pronounced C sharp) and Java. It is still one of the most used programming languages, but lacks support for some of the newer concepts in programming, like adopting an object-oriented approach rather than a procedural one. It is also more of a low-level programming language compared to the languages mentioned. Both Java and C# are fully are object-oriented, while both PHP, C++ and C are generally procedural languages. What this means is that the code is executed in a top-down manner, much like we human read text. Object-orientation is a concept of abstracting pieces of code into more human-understandable concepts. A much used example in this regard, is a toaster. An object of the type "Toaster" may have encapsulated logic for interacting with it, for example putting in an object of bread and pressing down the toaster mechanism. The main difference between the two is the way we think about code and organize it. A high level programming language has more built in features than a low-level one. A high level language may for example make it a lot easier for you to perform operations to files, like reading it's content, adding new content and such common tasks. In a low-level language, you may need to combine a series of commands to do the same thing. A low level language will therefor often be clear computer instructions, (that may actually be C commands themselves, C is widely used in operating systems) while high-level languages will read much more like normal english. It's hard to recommend one over the other. The ultimate coding language is obviously assembly code (Both Java and C# code is parsed to this internally), but that is generally not human-friendly as most men do not think like robots. That is the reason why high-level programming languages and object-orientation exists. There are trade offs to be considered, so no language is perfect for every purpose. I suggest you research each of these languages strengths and weaknesses, read about some general programming concepts and talk to other that has a Master in programming for you choose. Hope this is somewhat helpful, at least gives you some clues to where to begin.
×
×
  • Create New...