/
MY_Form_validation.php
44 lines (39 loc) · 1.11 KB
/
MY_Form_validation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter MongoDB Library
*
* A library to interact with the NoSQL database MongoDB.
* For more information see http://www.mongodb.org
*
* @package CodeIgniter
* @author Alessandro Arnodo | a.arnodo@gmail.com | @vesparny
* @copyright Copyright (c) 2012, Alessandro Arnodo.
* @license http://www.opensource.org/licenses/mit-license.php
* @link
* @version Version 1.1.0
*
*/
/**
* MY_Form_validation
*
* Override core methods forcing them to interact with MongoDB.
* @since v1.1
*/
class MY_Form_validation extends CI_Form_validation{
public function __construct($rules = array())
{
log_message('debug', '*** Hello from MY_Session ***');
$this->CI->load->library("cimongo/cimongo");
parent::__construct($rules);
}
/**
* is_unique
*
*/
public function is_unique($str, $field)
{
list($table, $field)=explode('.', $field);
$query = $this->CI->cimongo->limit(1)->get_where($table, array($field => $str));
return $query->num_rows() === 0;
}
}