First off I know the developer stopped working on this extension full time, but from what I understand there are still alot of people using it. Hoping someone can help me with this (hopefully simple problem!)
I'm trying to read the data I just inserted into MongoDB using the YiiMongoDbSuite extension.
The data is successfully inserted as I can see it via the mongo console.
The problem is when I try to retrieve it. Here's the code I'm running together - it inserts it (no problem), but can't retrieve it:
<?php
$new = new Character();
$new->playerName = "Yii-Insert-Test";
$new->playerId = "123456789";
$new->playerScore = "9001";
$new->save();
$findAll = Character::model()->findAll();
foreach($findAll as $result) {
echo $result->playerName; // result should be "Yii-Insert-Test", instead it's NULL
}
?>
It does get inserted though:
{
"_id" : ObjectId("54a0deda60fc21843100002a"),
"playerName" : "Yii-Insert-Test",
"playerId" : "123456789",
"playerScore" : "9001"
}
And here's my very simple model Character.php :
<?php
class Character extends EMongoDocument
{
public $_id;
public $playerName;
public $playerId;
public $playerScore;
public function getCollectionName()
{
return 'usercollection';
}
public function rules()
{
return array(
array('playerName', 'required'),
);
}
public function attributeNames()
{
return array(
'playerName' => 'Character Name',
'playerId' => 'Character ID',
'playerScore' => 'Character Score',
);
}
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
I feel like it's right in front of me but can't see what the problem is.
edit:
slowly figuring it out - looks like I am receiving data, but it's all empty - this is the mongoDB cursor. I'm already doing a forloop to iterate it, so I'll have to figure out what else I'm not doing.