codeigniter - Problems with MongoDB query -


i developing api using codeigniter , alex bilbies oauth2 , mongodb libraries. need mongodb query query document _id of 1 , access token null.

i have far not work:

$exists_query = $this->ci->mongo_db->select('access_token')->where(array('_id' => $session_id, 'access_token' != null))->get('oauth_sessions'); 

i tried too:

$exists_query = $this->ci->mongo_db->select('access_token')->where(array('_id' => $session_id))->where_not_equal('access_token', null)->get('oauth_sessions'); 

how can change query work?

this seems weird.. not using id's mongo provides??

if are, have use special mongoid function converts raw string mongo id. if not using default mongoid... should!

also why having set nulls?? mongo structure unspecific, if field isn't used dont need set null value it.. dont include field.. isn't mysql need store null values.. each row in mongo db can have different columns.. way when querying db can use native method in mongo check field exists..

use mongo way should used.. , wont have these issues having

your query should like

$this->ci->mongo_db->select('access_token')->where(array( '_id' => mongoid($session_id), exists => array('access_token' => -1)))->get('oauth_sessions'); 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -