4.4. Arrays
4.4.1. Simple Arrays
4.4. Arrays
« Previous
4.4.2. Array of Embedded Documents
Next »

4.4.1. Simple Arrays

AuthorDariusz Górecki

Just define a property in yours model, and store an array in it! YES This is that simple

Example:

class User extends EMongoDocument
{
    // ...
 
    public $myArray;
 
    // ...
}
 
$myArray = array('our', 'simple', 'example', 'array');
 
$user = new User();
 
$user->myArray = $myArray;
$user->save();
// that's it!
// in any time after when you get yours model form DB
$user = User::model()->find();
 
echo $user->myArray[1];
// will return 'simple' 
4.4.1. Simple Arrays
4.4. Arrays
« Previous
4.4. Arrays
Next »
4.4.2. Array of Embedded Documents