3 +----------------------------------------------------------------------+
4 | Copyright (c) 2009 The PHP Group |
5 +----------------------------------------------------------------------+
6 | This source file is subject to version 3.0 of the PHP license, |
7 | that is bundled with this package in the file LICENSE, and is |
8 | available through the world-wide-web at the following url: |
9 | http://www.php.net/license/3_0.txt. |
10 | If you did not receive a copy of the PHP license and are unable to |
11 | obtain it through the world-wide-web, please send a note to |
12 | license@php.net so we can mail you a copy immediately. |
13 +----------------------------------------------------------------------+
14 | Authors: Cesar Rodas <crodas@php.net> |
15 +----------------------------------------------------------------------+
18 class Users
Extends ActiveMongo
24 function my_selector()
27 $col = $this->_getCollection();
29 /* Build our request */
30 $res = $col->find(array('uid' => array('$gt' => 5, '$lt' => 10)));
31 $res->sort(array('uid' => -1));
33 /* Give to ActiveMongo our Cursor */
34 $this->setCursor($res);
36 /* You must return 'this' for easy iteration */
40 function username_filter(&$value, $past_value)
42 if ($past_value != null && $value != $past_value) {
43 throw new FilterException("You cannot change the username");
45 if (strlen($value) < 5) {
46 throw new FilterException("Name too short");
52 function password_filter(&$value, $past_value)
54 if (strlen($value) < 5) {
55 throw new FilterException("Password is too sort");
57 $value = sha1($value);
63 $this->_getCollection()->ensureIndex(array('uid' => 1), array('unique' => true, 'background' => true));