-
tiyowan posted...
Good job.
As someone who's been wanting to implement the active record pattern in my projects using something that plugs into CI easily, your series has proved to be informational and relevant.
What would be great is if you could include an episode in which you discuss some of the disadvantages of using active record, especially some of the general cases where they don't fit well with your domain model.
Perhaps you could use that as a segue into series about a more complex design pattern such as a data mapper using Doctrine or one of the other well-known libraries for CI.
I look forward to reading/watching more of your content.
-
splitfireX posted...
has anyone here used mongoDB?
-
splitfireX posted...
Hey i was wondering if there was any openID libraries you recommend using with codeigniter
-
splitfireX posted...
I am currently creating a codeigniter + HTML5 application for people to be able to download and I noticed when I implemented the MY_Controller way of doing things the codeigniter {elapsed_time} isn't working. Do you know what would could cause this or how to fix it? thanks
-
spamoom posted...
Thanks so much for all your help Shawn :) Any idea when you're going to record & upload the new vid? ;D
-
spamoom posted...
Just tried it. In my case I have Users > Contacts < Companies
$c = Company::first();
var_dump($c->users);
Gives me a list of the users :) Make sure that you're getting the pluralization correct in the models - that cost me a few hours haha!
-
spamoom posted...
Hey Shawn,
Been following your screencasts... One question, how would you approach a many-to-many relationship, broken down into 3 tables. The tables could be:
Operators > Coverage < Locations
Would you do two one-to-many relations with belongs_to and has_many?
In this example, I'm trying to figure out the best way of getting all Operators from the Location - let me know if you have no idea what I'm talking about ;D
- Sam
-
spamoom posted...
Found the answer! (haven't tried it yet)
After speaking to one of my Rails friends, he alerts me to the fact that I need to use :through
class Assignment < ActiveRecord::Base
belongs_to :programmer # foreign key - programmer_id
belongs_to :project # foreign key - project_id
end
class Programmer < ActiveRecord::Base
has_many :assignments
has_many :projects, :through => :assignments
end
class Project < ActiveRecord::Base
has_many :assignments
has_many :programmers, :through => :assignments
end
I know it's in ruby, but this explains the problem we are having and php-activerecord supports the through keyword! (Assignment is the middle table)
-
pascal posted...
Thank you for all these. I learned a lot. Now, we miss you so much! Please come back very soon! Thank again.
-
ian posted...
wow, one a week. I am so glad I found this site. I'm telling all my friends about this site and http://picofin.com/ ....Even if you miss a week or two. :-)
-
Yunus Aydin posted...
Hey,,
First of all thank you for these fabulous screencasts! They are verry good!
My question is are you going to make a part 7 anytime soon? I am having problems with making a registration form it would be great to get some help.
Ty.
-
Yunus Aydin posted...
....
-
Yannis posted...
Just to add to all the positive feedback, I have REALLY enjoyed your screencasts, and looking forward to new ones. I' ve been using ASP.NET MVC @ work for some time now and looking for PHP alternatives for personal projects and I must say, what I always loved in PHP is the tremendous amount of excellent community feedback! Please keep em' coming! Greetings from Greece!
-
Theshiftexchange posted...
Hi, great screencast.
I noticed there is now a flash spark, that seems to be similar in idea to yours?
http://getsparks.org/packages/flash_message/versions/HEAD/show
Do you think the functionality is the same? As already mentioned, we'd be very keen to see your version...
-
Shawn McCool posted...
You can use htmlentities and strip_tags or come up with a custom implementation. It's up to you. CI has an xss_clean sanitization filter built in. A lot of people think that it does too much. But, it's up to you.
-
Shawn McCool posted...
That's actually something that I'm going to talk about in the next screencast. I never direct people to another page. I always submit right back to where we are.
In order to really do forms right. I feel like I'm going to need to do some work and create a spark to add form functions. I'm not huge on the way CI does it out of the box. It's simply and it's fine. But, one spends a lot of time on it and i don't like that. It also makes it hard to use the same form for multiple purposes (adding and editing).
Anyway, I'm rambling. I'll talk about more form input stuff early/mid next week and that should leave everyone with a better method of working forms. It's difficult for me to straddle the line between the way i use codeigniter and talking about fundamentals. In reality I use the CodeIgniter way for many things, but I also deviate from it in many ways due to my experience with many web development languages, etc.
I think that I will try to find time to create a spark which improves CI's form code. In general passing data back with flashdata is the only solution when you direct someone off to a a different method. I prefer posting to the same method.
In general I want my screencasts to be 20-25 minutes at most. This one ran long and I had trouble finding a good time to end it. In a lot of ways I'm just working hard to keep them coming at a regular interval as my partner and I are pushing to release the new and complete launch version of picofin.com (which is currently in a beta-like state in both design and development).
-
Shawn McCool posted...
Thanks for the kind words. Yes, in general I am a fan of Phil Sturgeon's work. FuelPHP seems to be a really solid alternative to CodeIgniter that has a similar developmental philosophy.
-
Shawn McCool posted...
Thanks for the feedback. I really do appreciate it. I have been uploading a bunch of new screencasts, lately! More to come next week I imagine.
-
Shawn McCool posted...
Thanks for the feedback. After having gotten multiple messages on this exact subject I think that it may be actually better for me to write an article on flash messaging rather than put screencast time into it. I'll try to get that up shortly. This next weekend is a bit of a bind for me but look for something to be up mid-late next week.
-
Shawn McCool posted...
Thanks for the feedback, Tiyowan.
ActiveRecord is the right approach for most websites. Normalization techniques in general are implementations of object-oriented data. Whenever your data is stored in an object-oriented manner an ActiveRecord or DataMapper implementation is probably the right choice. I personally prefer ActiveRecord and SQL because my clients almost always need medium / small sites. For larger sites or for hobby projects no-sql would probably be something that I'd recommend.
I hope you check out my newer videos and give me some feedback on some of the things that could be improved on. I value your feedback.
-
Shawn McCool posted...
Sounds like a good idea to me.
-
Shawn McCool posted...
PHP ActiveRecord is based on Ruby on Rails' ORM. So, it's virtually always the same methodology.
-
Shawn McCool posted...
Not at the moment, sorry.
-
Shawn McCool posted...
I'll do my best to continue pumping one out a week. I'm really looking forward to next week's. I wanted to talk about a number of things in part 6 and then didn't really have time to do what I wanted with the source. Next week's will basically be part 2 of this one's.
-
Shawn McCool posted...
I don't know much about the Yii framework except what I've heard from other developers. I'm sure that it's perfectly viable. I think that CodeIgniter is the easiest framework to modify out of those that I've used. This makes it ideally suited to me because I want to take a little from Rails, a little from this, and a little from that.
In the end it's about what you're most comfortable with.
-
Shawn McCool posted...
Hey, it's my pleasure. I love making these kinds of things. I appreciate the awesome feedback. I plan on making part 7 this week.
-
Shawn McCool posted...
Check your uri_segment parameter for pagination?
-
Shawn McCool posted...
All of our applications use the same kind of 'modified' CodeIgniter that we're using in our screencasts. They're a bit more modified in order to make development quicker and to make our code more flexible. Over time I'm going to be talking about how I simplify CodeIgniter development more. I really do hope that I get time to improve upon the CodeIgniter form system in a spark within the next week or so.
We're getting ready to release the .. 1.0 version of Picofin. It's currently in a beta-like state and we've learned a lot by seeing how people are using the site and by getting feedback. We've been working hard to update the system and we're really proud of what we're going to be releasing.
-
Shawn McCool posted...
@chris
You'd need to use $property->commisions[0]->name as it'd be an array since it's a has_many relationship.
Check out: http://www.phpactiverecord.org/projects/main/wiki/Associations
At the very bottom you'll see the guide for self-referential associations. In that they give you a method to assign a particular model to a particular name. The association doesn't have to be the name of the model class.
-
Santa posted...
Hey Shawn, done with part 6 now ... awesome and thanks for teaching so many important things!
-
Nick posted...
Shawn, thanks soooo much for posting these. I just watched all of your videos and just finished part 6 and they have helped me out a TON. It would be awesome to see more if possible. Thanks, -skcin7 (from #codeigniter on Freenode)
-
Nicholas Ruunu posted...
Hey Shaun, I really love these screencasts. I started watching a long time ago when you were improving models. I hope you'll continue doing them as I'm checking in almost everyday for the next one.
I'm trying to get my work to open their eyes to ORM so if you could do some more advanced relations in the models that would be awesome.
-
Niccu0921 posted...
Can you make a tutorial on a Admin crud? I think it would be perfect after seeing this tut! =) I am new to this technology(active record, CI) an I've been diving in to it for about a week already. Your tuts are very easy to learn.. Keep up the good work Shawn!
-
Nguyen Loc Duy posted...
I'm waiting for your next cast! It's hotter than Spider Man 4 :D When will it be available?
-
Nguyen Loc Duy posted...
I watched all 6 parts of this series in one shot! These even better than premium tuts, thanks a lot Shawn!
-
Nageeb posted...
Great screencast! I'm working on a pet project and going back every week to refactor after every new video. What an excellent way to learn php-activverecord!
-
Marhnix posted...
Thanks for the tutorials. I just finished the whole serie and i've learned a LOT !
Can't wait to see the next one. Your programming style is just awesome !
-
Justin Seiter posted...
Hey Chris! Yes, Picofin is a CI app and as a designer I couldn't be happier with the simplicity of its controller methods.
Thank you for signing up by the way. We're very close to launching a revision:
http://twitter.com/#!/picofin/status/119089624172871681/photo/1
-
Jordi Pàmies posted...
Pretty nice screencasts series Shawn.
Quick question, which one is the best way to prevent XSS attacks on this add comment form??
Thanks!!!!
-
Jon Warner posted...
Just wanted to give a big thank you for this series. Not being a big php developer, I started looking at CI a few months ago as a way to prototype ideas I had, with the intention of bringing in a proper backend developer should I ever decide to push a prototype live. That fell by the wayside due to other work.
I saw, week ago or so, this series on the CI website and have slowly worked through it as time allows. I was still sceptical and frustrated by the middle of ep5, but things have started slotting into place. I'm still getting used to the fact that AR makes a lot of assumptions and that makes me a bit nervous by not declaring certain things explicitly - but I've seen the light and it's worth moving towards ;)
Many thanks again - have a great Xmas.
-
Jon posted...
Great series, thanks!
I’ve got a quick question about validation with php activerecord, maybe you have an idea. I created a user model and added some validation rules. Now, when I create a new user, it works well that it validates e.g. the username, email and password (presence of, format etc.) but what if later I just want to update the email with a simple form (input: new email). I get validation errors that username and password are missing. Save(false) I don't want to use since some of the rules still make sense like the format of email rule. Is there a way to let it just validate some not all of the attributes? Would greatly appreciate a hint. Anyway, thanks again!
Are you planning to continue this series? :-)
-
Jimmy Pettersson posted...
Great as always!
I'm currently learning FuelPHP but since it's similar in many ways to CI these casts can almost me directly applied to FuelPHP as well. Looking forward to the next one!
-
Ian posted...
Thank you for another awesome tutorial!
The information in part 5 and 6 about ORM, mass assignment, and N+1 is important information to know, and the method of managing the views is very logical and easy to extend and maintain.
-
Ian posted...
Shawn,
I feel like a dummy for some of my comments on these tuts. I get in a hurry sometimes and miss things like your explanation of the updated MY_Loader.php file which was in a big yellow hard to miss box.
Anyways, I created my own implementation of the flash helper file you mentioned in part 6 and wanted to share. Feel free to let me know how I did since this is the first helper I made. I'd like to know if I made any idiotic mistakes or could do things better.
I put it in a rough howto text file and tried to explain the steps if it helps anyone out.
Here's the dl link http://metrotechpc.net/download/flash_helper_howto.txt
Criticisms and comments welcome from everyone else
Thanks
-
Ian posted...
Hey cool. I just saw this and checked it out. I think it's overkill to make a spark out of it since it's just a library and a lang file but it's definitely better written, more functional, and better documented than what I came up with.
I was here checking to see if there was a part 7 :-) I have used and abused the Internets supply of CI tutorials until there is nothing left. Oh no, now I have to actually write some code on my own lol
-
Guest posted...
Hey Shawn, I like videos.
And they were very good help when you upload them.
But with the new versions of codeigniter,php-activerecord(spark),my_loader.php.
This demo code is becoming not valide. The default Mode::find($some_id) is broken when there is no entrie with such id, do you know for a solution ?
-
Guest posted...
Are you buy chance going to cover creating new accounts/registering. I know you showed something like that in the login video but it didn't do so through forms. Thanks!
-
Debow posted...
Wow, it was a hunt but I found the issue. I was missing a ',' after ostype => 'OS'
-
Debow posted...
Hey Shawn it was (5) from my old code I've tried 0-5 :) and nothing works. That's why I was wondering if it was invoked differently.
This is the controller function.
http://pastie.org/2868622
-
Debow posted...
Has anyone tried using pagination with AR? Everything I've tried doesn't work. I'm taking my code from a working CI typical setup. Is there a different way to invoke pagination. When I hover over the links the uri looks correct but when they are clicked they never move to the new page/display. I can past the code if you like but wasn't sure if there was something easy I was missing with the config setup. Thanks.
-
David posted...
Your screencasts are very helpful! I really hope you'll find the time to continue this series. Thanks a lot!
-
David posted...
I'm also very much interested in your approach to a form library. Would you mind outlining your ideas briefly? Thanks
-
Darkness.com ☥ posted...
Just finished all 6 vids and wanted to thank you for taking the time to create them. I've been exploring ORMs to use and phpActiveRecord is looking pretty good. I also wanted to thank you for teaching some great CI tricks in the series. I've picked up a lot of useful techniques just watching you develop.
-
Daniel Cedilotte posted...
Thanks for yet another great set of CodeIgniter Tuts. I'm not new to CI, I've been using it for 4 or 5 years now +/- and thanks to tutorials by you and Jeffrey Way of Tuts+, I've been able to greatly improve my coding style. And by that I mean simply learning how people do the same things I do but differently and adding those techniques to my own ways.
Out of curiosity mostly, I'd really like to see this flash "helper" function and _flash.php partial you were talking about. And also to compare with the ones I created.
-
Daniel Cedilotte posted...
Cool. Thanks Shawn.
-
Daniel posted...
I love your tutorials. I am just starting out and trying to learn a proper framework and your tutorials have given me to want to push ahead with learning CodeIgniter.
It would be nice however, if there was a way to download your tutorials so they could be viewed offline. Any chance this could be done!?
Thank you once again for sharing the knowledge with the rest of us!
-
Chris Schmitz posted...
Right, I have the correct data pulling through my has_many through associations, but I don't get how to access it. For example, I have many users for each property through payments, but there are different types of payments. I want to be able to be able to access the user by doing something like "$property->commission->name" where "commission" is the payment type, but I can't figure out how to do it. I just have access to the array of users who are related to the property.
-
Chris Schmitz posted...
I've been enjoying these screencasts a lot. Thanks for the work you've put in to them!
I'm just starting to use PHP ActiveRecord in some projects and I'm kind of torn about how to handle validation. I like that using an ORM allows you to set all of your validation rules in the model along with the relationships, but I miss being able to use the set_value() method to re-populate the form upon an invalid submission. Do you always pass the submitted form data back to the view with flashdata or have you found a more elegant way to handle this?
-
Chris Schmitz posted...
Cool, looking forward to the next screencast!
Yeah, I hear ya about the way CI handles forms. There is something to be said for its simplicity, but if you're doing a lot of application development it can get rather tedious.
I'd be interested to see your approach to a form library for CI. Let me know if you ever start to build it out and have a public repo for it. Have you ever played around with Dan Horrigan's Formation library?
BTW, I signed up for Picofin the other day, it looks pretty cool. Is that a CI app?
-
Chris Schmitz posted...
I am trying to figure this out too... I have Properties > Payments < Users and I can't figure out how to setup the associations to access the users that belong to a property through the payments.
-
Chief posted...
Hey Shawn,
This is the first time I've used frameworks, however I've been using MVC design and OOP php for a good amount of time now. What would you recommend for a large scale project? Codeigniter or Yii framework. I've been reading both frameworks before I start coding, code ignitor seems pretty easy for me to learn, YII looks like its the right way of doing things, not that easy, but I can always code while I have their class reference on my second monitor. I wish there was someone making YII video's like you, to be honest!
-
Alix posted...
Hey, your tuts are very nice. However I'm having trouble to autoload sparks with CI 2.1.0, any ideas?
THanks