findAll not returning anything

Can anyone tell me why this is not returning any rows from the db.

$users = User::model()->findAll(‘room_name=?’, array($_POST[‘LoginForm’][‘room’]));

$_POST[‘LoginForm’][‘room’] is a valid variable as I’ve checked its value. When I use just the find method with the same criteria it returns one row as expected, but the findAll returns nothing.

I’m sure I’m missing something quite simple, can anyone spot it?

How about like this?

$users = User::model()->findAll(‘room_name=:room_name’, array(’:room_name’=>$_POST[‘LoginForm’][‘room’]));

Thanks Joshua, I’m somewhat of a php novice. I have that working now, for my next trick I need to find the best way to pass $users to a view. It’s an array of objects obviously so I imagine passing via the URL is a bad idea, as in , $this->redirect(array(‘room/openRoom’, ‘roomname’ => $model->room, ‘users’=>$users)); In fact, that gives me an error anyways, urlencode() expects parameter 1 to be string, object given. Any advice?

You’re right, you can only pass strings as GET parameters to $this->redirect. If you use $this->render() instead, you can do what you want. Can you move the logic that gets the array of users to the room controller?

Why don’t you just store the room name in a session variable, especially if they’re using that to ‘log in’.