Weird "blank page"

I’m relatively new to Yii, been using it for a couple of weeks, and got used to it, but on occasion I get some error without any message to tell me what is wrong.

I have several models in my application so far and calling them like this…

ModelName::model()

…all works fine.

Anyway, now I’ve created another model, and even if I tried renaming it, I cannot seem to access it. Well, I don’t get the error that the model doesn’t exist, I just don’t get anything out, and anything after the line where I call it doesn’t execute.

Here’s exact lines of code…

print_r(GamesInProgress::model());

echo ‘a’;

die();

…needless to say, print_r doesn’t display anything, and echo never happens. If I rename my “GamesInProgress” and call some other model, everything works fine. In the code above, I don’t get the message that the model doesn’t exist, that php file doesn’t exist. I just see the last page I saw when I first got there (if this sentence seems confusing, in other words, if I comment print_r() line and see echo ‘a’ on the screen, and then uncomment it, I will still see ‘a’ on the screen). Otherwise, I get the message “remote server or file not found”.

I don’t know what to do or how to catch the error or display something. The model is pretty simple, a couple of integer fields is all there is in the table, and I created model with gii and all went well.

Not sure if i understand but did you also check Apache’s error logs? It could be that apache throws a “segmentation fault” (at least that’s what i occasionally see in cases like this).

Nope, no error in the Apache log file. It doesn’t even seem to call the static model() method for this class, and I can’t get any error message or anything telling me what is happening except getting the message like the page I am trying to refer doe not exist (but obviously does, because if I comment that line of code, it works fine).

Here is one more time what I do… this time literally.

1

I have a table called ‘games’ with appropriate GamesController.php which I created using gii, and also created CRUD.

class GamesController extends Controller {…}

2

Inside the controller I have actionPlay() method which looks like this…

public function actionPlay() {

GamesInProgress::model();

echo ‘a’;

die();

}

3

GamesInProgress is a model only, and reads from the table ‘games_in_progress’ (I tried using one-word name, that doesn’t fix the error I am facing). It is a simple table of 5 integer fields.

If I try to call any other of my models with “ModelFilename::model();” I can print_r() its content quite fine. I am not sure if I am missing something here, this model I use I just created so I can call it like this and use the AR method to get database data. But for some reason, when I try calling GamesInProgress::model(); I don’t get anything out, I can’t get any error. And from what I tried, it doesn’t seem to even enter the method…

class GamesInProgress extends CActiveRecord {

public static function model($className=CLASS){

echo 'aa'; die();


return parent::model($className);

}

…with all other methods, this yields in outputting ‘aa’ and dying right after. With this one, it doesn’t happen.

Can anyone tell me why?

Also, when I try crud generator with gii, if I type in GamesInProgress, I also get the blank page saying "remote server or file not found" with the text like this…

"You tried to access the address http://localhost/yii/equiz/index.php/gii/crud, which is currently unavailable. Please make sure that the web address (URL) is correctly spelled and punctuated, then try reloading the page."

…which is same thing I get when trying to call the GamesInProgress::model();

Can something be wrong with the database? Will try to create table and model anew, not sure what else is left to try.

Okay, I fixed it. There is really no explanation as to how. I renames table ‘games_in_progress’ to keep it, and created a new one with same name and added field by field (after each time creating model via gii) to see when everything will collapse. Finally, I ended up with the replica of the table with same fields, and the model is working fine. I don’t know how to explain this or what could’ve caused the problem.

Thanks for the help, Mike. I really don’t know what could’ve cause this, but maybe this post can help someone who may run into same problem.