after installing gii (according to blog and other tutorials), CRUD doesn’t seem to work. Doesn’t matter what I fill in the create/update forms, after submitting the form nothing happens (no error message, same page, no changes in db). The only thing that works is delete function.
It doesn’t seem to have anything to do with privileges. Adding a simple mysql_connect(…), mysql_select_db(…), mysql_query(INSERT…) in to controller adds values to database. The last query in the log is SHOW CREATE TABLE blog in a green background, so it seems to be working.
Really frustrated, as it is one of the first steps in learning yii, and it doesn’t work.
line in your controller file(create, update function). See whether there are errors or not.
Btw, do you add some function like beforeSave() in the model? If you do, check whether it has return or not. I ever got similar case with you, that’s because I forgot to add the “return parent::beforeSave()”
Perhaps the tutorial is not right or something has changed, but a code generated by gii lowercased the model name. Well, if the naming convention says that model should start lowercase, then the tutorial is wrong.
No, I didn’t. The thing is, that model name is still Blog (as I understand from this code):
class Blog extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @return Blog the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
And in the form, I get generated
name="Blog[title]"
etc. But the controller expects an array named blog, not Blog.
Now I tried generating new CRUD controllers, first inserting blog, then Blog, and although it says the Model Class is case-sensitive, both times it generated same thing (although there is no model called blog) with a $_POST[blog] in controller.
It’s strange, because Gii checks if the models exists…
I just tried to enter a model in lowercase (Gii-CRUD generator) and when I press Generate I get the error - Class ‘kontakt’ does not exist or has syntax error. (kontakt is my table and Kontakt is the model)
So makes me think that you have two models "Blog" and "blog" - check your model directory
If it does not help please try all from the begining - create a new webapp (ie. yiitest) and try there to make this working…