copy blog apps get error

Dear all, I’m new with PHP and YIIFramework, so I’m trying to write the blog apps from scratch, and copy it step by step.

In a first few steps, everything goes OK, but when I came to the Post relation function, the browser just get not fount message. if I revert the relation function code to the code generated by system, and browser get OK again. so it must be the problem of this function, however I compared this function with demos/blog/protected/models/Post.php’s corresponding function, it’s identical.

And I found ,the problem is at the const value Comments::STATUS_APPROVED, if I replace this value with a numerical number, such as 1, the page could be viewed correctly.

So my question is how the blog demo works fine, but mine gets wrong?

I have configure the following parameters in config/main.php

16 ‘import’=>array(

17 ‘application.models.*’,

18 ‘application.components.*’,

19 ),

Comment Class requires two constants to be defined to work properly:


class Comment extends CActiveRecord

{

    const STATUS_PENDING=1;

    const STATUS_APPROVED=2;

    ......

}

Marcanuy, Thanks for your replay. I have defined the const value in Comments class. I found my bug is mis-spelling of the constant value. It’s really a shame!

But could any one tell me how to debug the php script? It doesn’t like C language have a compiler to detect the spelling things and some debug tool to setup a breakpoint at running time.

Yeecho, you can use XDebug extension for PHP for debugging PHP scripts.

Thanks a lot. I shall have a look at it.