We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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



98.9k

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)
    )
);


10.0k

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



10.0k

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



10.0k
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



98.9k

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