How work with number fields? How exclude fields?

Hi, how I can work with number fields, like:

$cursor = self::find(array(
    '155' => array('$exists'=>true)
));

And how I can get needed fields?

$cursor = self::find(
    array('user.name' => 'john'),
    array('user.name' => 1)
);

Thanks.

P.S> About first question i look in source code, in my opinion it's "crutch". @phalcon



81.3k

Both codes are fine, however you need to use an extra array:

$cursor = self::find(array(
    array(
        '155' => array('$exists'=>true)
    )
));
$cursor = self::find(
    array(
        array('user.name' => 'john'),
        array('user.name' => 1)
    )
);


4.6k

Ofcourse, i forgot this, but still not work. Please wait 2 minutes i give to you error.



4.6k

Warning: Phalcon\Mvc\Collection::writeAttribute(): Property should be string in /Users/r



4.6k
edited Nov '14

kernel/object.c 939

if (Z_TYPE_P(property) != IS_STRING) 
    php_error_docref(NULL TSRMLS_CC, E_WARNING, "Property should be string");
return FAILURE;

@phalcon



81.3k

I think there could be probably a limitiation in the ODM as it's currently only accepting string properties