Skip to content

Instantly share code, notes, and snippets.

@steppefox
Created October 29, 2013 11:07
Show Gist options
  • Save steppefox/7212671 to your computer and use it in GitHub Desktop.
Save steppefox/7212671 to your computer and use it in GitHub Desktop.
PHP MongoYii Snippets
$c = new EMongoCriteria();
$c->addCondition('is_visible',(int)1);
$c->sort = array('publicated_at'=>-1); // ASC:1, DESC:-1

$pages = new CPagination(Feedback::model()->count($c));
$pages->pageSize = 6;
$pages->applyLimit($c);

$models = Feedback::model()->find($c);

// OR
array('$or' => $value);

// <>
array('$ne' => $value);

// <=
array('$lte' => $value);

// >=
array('$gte' => $value);

// <
array('$lt' => $value);

// >
array('$gt' => $value);
	
// VALIDATORS	
array('url','EMongoUniqueValidator', 'className' => __CLASS__, 'attributeName' => 'url'),
array('colors','subdocument', 'type' => 'many', 'rules' => array(
    array('title,type','required'),
),

Validation subdocuments

array('colors','subdocument', 'type' => 'many', 'rules' => array(

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