<?php

/**
 * MY_form_validation描述
 *
 * @author 邱伟平
 */
class MY_form_validation extends CI_Form_validation {

    public function __construct() {
        parent::__construct();
    }

    /*
     * 验证码
     */

    public function valid_captcha($str) {
        $saved = $this->CI->session->userdata("captcha_code");

        if ($str != $saved) {
            return FALSE;
        }
        return TRUE;
    }

    /*
     * 是否存在
     */
    public function valid_exist($str, $field) {
        list($table, $field) = explode('.', $field);
        $query = $this->CI->db->limit(1)->get_where($table, array($field => $str));

        return $query->num_rows() === 1;
    }

}

?>
