Skip to content
This repository was archived by the owner on Jul 11, 2024. It is now read-only.
This repository was archived by the owner on Jul 11, 2024. It is now read-only.

->Save() (simple update) \morph\property\Date do not work #45

Description

@Gorbov
class DBObject extends \morph\Object
{
    public function __construct($id = null)
    {
        parent::__construct($id);

        $this->collection('TestObjects');

        $this
            ->addProperty(new \morph\property\Date('Date'))
            ->addProperty(new \morph\property\String('TestString'))
            ;
    }
}
$test = new DBObject();

try {
    $test->loadById(new \MongoId('50e53522ce9f57dc0f00000e'));
} catch ( Exception $E ){
    return FALSE;
}

$test->Date = time();
$test->TestString = 'OK';

$test->save();

DB:

(array) Array
(
    [_id] => MongoId Object
        (
            [$id] => 50e53522ce9f57dc0f00000e
        )

    [_ns] => DBObject
    [Date] =>
    [TestString] => OK
)

but!

print_r($test->__getData());

// return:
(array) Array
(
    [_id] => MongoId Object
        (
            [$id] => 50e53522ce9f57dc0f00000e
        )

    [_ns] => DBObject
    [Date] => MongoDate Object
        (
            [sec] => 1357198626
            [usec] => 0
        )
    [TestString] => OK
)
print_r($test->__getData(TRUE));

// return:
(array) Array
(
    [_id] => MongoId Object
        (
            [$id] => 50e53522ce9f57dc0f00000e
        )

    [_ns] => DBObject
    [TestString] => OK
)

But the New is work fine!

$test = new DBObject();
$test->Date = time();
$test->TestString = 'OK';
$test->save();

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions