Blog tutorial is a mess

I followed the tutorial to the part "Displaying Posts" and i got this error


CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'status' in 'where clause'

Anyone know why? please help

UPDATE: it was the comment table missing status.

So it was framework tutorial/sql error? If yes, please submit a ticket: http://code.google.com/p/yiidoc/issues/list

The blog app has been getting some major changes as of late so that’s probably why.

more like a lot of missing information that left you hanging to figure it yourself. I do submit a lot of ticket.

Thanks. The more useful tickets Yii team is getting, the more Yii community will benefit.

I have been trying to get the blog tutorial running, and have been getting errors after (seemingly…) following the instructions in the section on customizing the Post model. There is a chance I might have done something incorrectly… ;)

Are the files in the demo directory up to date? I may just try to use them rather than build things up via the tutorial.

Thanks, Iam very interested in YII and hope to learn much from all of you

Michael Sullivan

You’ll find the blog demo in <your-yii-dir>/demos/blog. The files in svn was updated five days ago.

/Tommy

Thanks I am working my way through it. Can you tell me what file in the blog code actually creates the hash (and writes it to the user table) that the validatePassword function validates? the users that I create still have the password in cleartext. I can’t seem to figure out the file / function that takes the form data (password and salt), creates the hash and writes it to password.

Thanks much,

Michael Sullivan

I can see that the hashPassword function actually creates the password, but after looking at the example record in the tbl_user table, it looks like the salt field is populated by a hash as well, and I can’t figure out where THAT happens, and I am not sure exactly where hashPassword gets called.

Beware I haven’t tried out the blog demo (or tutorial) for one year and there’s some new functionality I haven’t seen before.

The blog demo is incomplete. You can’t register users. One existent user record is provided in tbl_user. There’s no code to generate the salt (e. g. generateSalt() isn’t called anywhere).

You’ll find the call to validatePassword() in /wwwroot/blog/protected/components/UserIdentity.php.

There’s one place, though, in the blog demo code where (hardcoded) salt will be stored to the DB. It’s the test fixture at /wwwroot/blog/protected/tests/fixtures/tbl_user.php

/Tommy

yes, I gathered that the registration was incomplete - thanks for the pointer on the salt - but when I looked there I didn’t see a hardcoded value but rather ‘’

I may take a look at some of the suggestion for RBAC in the comments and forums and try to bolt that on to the blog – if anyone has done that and could offer suggestions / help that would be great!

thanks

Michael

Well I got far enough to be able to add users, with the md5() and salt working, and just about everything works (with some tweaking on accessRules()…

but I still have one really wierd glitch - on the very first page, at /www_root/blog/index.php, instead of getting the /protected/views/site/index.php message like a freshly-generated app does, instead, I get this error message: The system is unable to find the requested action "index".

if I hit the "Home" menu choice, I get /www_root/blog/index.php?r=post/index and all is well, but the "breadcrumb" version of home takes me back to /www_root/blog/index.php and it is borked… any ideas?

Thanks much!

Michael

You need to probably add to protected/controllers/SiteController.php:




public function actionIndex()

{

    // renders the view file 'protected/views/site/index.php'

    // using the default layout 'protected/views/layouts/main.php'

    $this->render('index');

}



…and protected/views/site/index.php:

whatever your heart desires… here is default:




<?php $this->pageTitle=Yii::app()->name; ?>


<h1>Welcome to <i><?php echo CHtml::encode(Yii::app()->name); ?></i></h1>


<p>Congratulations! You have successfully created your Yii application.</p>


<p>You may change the content of this page by modifying the following two files:</p>

<ul>

        <li>View file: <tt><?php echo __FILE__; ?></tt></li>

        <li>Layout file: <tt><?php echo $this->getLayoutFile('main'); ?></tt></li>

</ul>


<p>For more details on how to further develop this application, please read

the <a href="http://www.yiiframework.com/doc/">documentation</a>.

Feel free to ask in the <a href="http://www.yiiframework.com/forum/">forum</a>,

should you have any questions.</p>