public static function collection($collection = null) { if ($collection !== null) { self::$collection = self::db()->{$collection}; } return self::$collection; }
public function action_mongo() { MDB::$config = Kohana::$config->load('database')->mongo; $config = MDB::config(); #d::v($config); $mongo = MDB::mongo(); d::v($mongo); $db = MDB::db(); d::cl($db); $colle = MDB::collection('test'); d::cl($colle); $data = array('data' => 'test'); $insert = MDB::insert($data); d::v($insert); $find = MDB::find(); d::cl($find); d::v(iterator_to_array($find)); $gridFS = MDB::gridFS(); d::cl($gridFS); $remove = MDB::remove(); d::v($remove); }
public static function is_unique_email($email) { return !MDB::collection('users')->findOne(array('email' => $email), array('email' => 1)); }
protected function __construct() { MDB::$config = Kohana::$config->load('database')->mongo; $this->collection = MDB::collection($this->collection); }