I am a newbie just started learning yii framework. I’ve created CRUD operations with yii but i want some extra functionality in my view.php of Association model. So I added some extra code in that to insert my textArea text into my database with submit button. This code works perfectly fine outside Yii framework application as i tested it with simple html file calling this same php excluding yii code from this file.
I am getting either of these bugs:
If i change POST to GET, “Unidentified Index : $_POST[‘comments’]”
If i keep as it is(current code), it does nothing, my database is not updated.
Any help will be much appreciated. Thanks in Advance.
Surely I’ll go through the basics of MVC, thanks again for the links.
So is that i cannot access the GET and POST variables with the Views ? Shall i access those with the Controllers instead ?
I got the Idea such as I can put SQL statements and some logic in Model, I can access it through controllers and present in Views. But not sure how so If you can just give me a hint or example of how I shall run that simple PHP script if i wanted to with MVC ( yii framework ) that would be great.
In fact you can access GET and POST in view, but you would be better not.
Yes, you are right.
Please take a close look at "create" and "update" actions of gii-generated CRUDs. Examine how Model, View and Controller work together in them. They will show you how to insert/update a database record using Yii framework.
It may look overdoing for a simple task, especially when you have good experience in plain PHP programming. But it will surely help you a lot when things get larger.
Another thing you might not like at first might be AR (Active Record). But I’m sure you will love it in the end.