redbullmarky Posted April 8, 2007 Share Posted April 8, 2007 you kinda need to remember though that the examples given in this topic are just that - and that is REALLY skimming on the surface of what a framework can do in one small area of your site. But consider stuff like validation, RSS, AJAX, Emailing, nice URL's for SEO, amongst many many many other things - all areas that time after time get asked about in terms of "how do I do this?" - though whilst its still advisable to find out, a framework will do much of this sort of stuff for you. your example is pretty much there, although like 448191 says, it's better to delegate responsibility elsewhere rather than doing any crunching within. so you might have a model class called 'User' that extends the 'Model' class (and any class extending 'Model' will also have the same methods available which is where the usefulness really comes in): <?php class Model { public $tableName = null; function get($conditions) { $query = "SELECT * FROM {$this->tableName} WHERE $conditions"; // rest of code here return $result; } private function __call($name, $param) { if(substr($name, 0, 5) == "GetBy") { $field = strtolower(substr($name, 5)); $conditions = "$field = '{$param[0]}'"; $result = $this->get($conditions); } return $result; } } class User extends Model { public $tableName = 'users'; } $myuserinstance = new User(); $user = $myuserinstance ->GetByUsername('redbullmarky'); ?> but yeah - ultimately you've got the gist. useful, huh? Cheers Mark Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/page/2/#findComment-224369 Share on other sites More sharing options...
Liquid Fire Posted April 8, 2007 Author Share Posted April 8, 2007 yeam pretty useful. well first of all, what is SEO? Aalidation, yea is would be nice not to have to deal with form validation each time i have a form but i can just build and for validator myself is need be. RSS is not a feature i am worried about as i feel there is no real need for it right now. AJAX is something i want to learn so it would make no sense in me using a framework to do if for me. I am going to be build an email class seperately anyways. This is something i am going to be pitching at work since right now we are rebuild some of the section of our website from scratch and fell something like Cake will be useful and maybe they will not see switching to ruby for Rails as needed becuase Cake can do most of the thing ruby on rails can. Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/page/2/#findComment-224425 Share on other sites More sharing options...
redbullmarky Posted April 8, 2007 Share Posted April 8, 2007 well first of all, what is SEO? ... Cake will be useful and maybe they will not see switching to ruby for Rails as needed becuase Cake can do most of the thing ruby on rails can. SEO = search engine optimisation. One of the weird things with many of these frameworks is that you'll probably never use $_GET ever again - but more of a segment approach. It's weird at first, but when you get used to it, you realise how much crap you throw in the URL. example? http://www.example.com/product.php?category=mylist&item=123 would become: http://www.example.com/products/mylist/123 which from what i've both read and experienced, REALLY helps getting those pages indexed. Google is not really a fan of pages that have lots of URL parameters - so simplifying it into a more readable fashion does wonders. A look at the URL's of blogs and many "Web 2.0" sites will show you how it's not all about the ? and the & as for your last point(s), dont just see the examples (RSS/validation/AJAX) as all there is - those were (personal) examples of those tasks that when I used to sit facing another project, I thought "*sigh* not another bloody contact form/Rss feed, etc" - now I can just get on with app/site specific stuff. In my opinion, Rails (and Ruby) itself is sideways comparable to Cake (and PHP). If you know PHP, stick with it as Ruby doesnt REALLY offer any additional benefits (due to my old argument about the languages being more powerful than their results). As a beginner, maybe one might go either way and both ways would be fine - however, when the ultimate gain is to earn money and put bread on the table, best to stick with what you know rather than tackling "that" learning curve again. And in my other opinion - if Cake doesn't do something that Rails can - write some code to make it! That's much easier than learning a whole new language and starting from the bottom of the ladder again. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/page/2/#findComment-224454 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.