diff options
author | Eric Barnes <eric@ericlbarnes.com> | 2011-12-04 06:01:17 +0100 |
---|---|---|
committer | Eric Barnes <eric@ericlbarnes.com> | 2011-12-04 06:01:17 +0100 |
commit | cccde9650f061eee602013a1f3695a293f46d13e (patch) | |
tree | b4ef7f0c5b7f9e457c9b0ca6b014402045aea643 /system/libraries | |
parent | bce4140f05f9e8642554eac7aee232023b9a93d9 (diff) |
Fix for is_unique when you are not connected to a db. Refs: #724
Diffstat (limited to 'system/libraries')
-rw-r--r-- | system/libraries/Form_validation.php | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 5663da981..918f6904c 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -5,9 +5,9 @@ * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE - * + * * Licensed under the Open Software License version 3.0 - * + * * This source file is subject to the Open Software License (OSL 3.0) that is * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: @@ -949,7 +949,7 @@ class CI_Form_validation { return ($str !== $field) ? FALSE : TRUE; } - + // -------------------------------------------------------------------- /** @@ -962,10 +962,13 @@ class CI_Form_validation { */ public function is_unique($str, $field) { - list($table, $field)=explode('.', $field); - $query = $this->CI->db->limit(1)->get_where($table, array($field => $str)); - - return $query->num_rows() === 0; + list($table, $field) = explode('.', $field); + if (isset($this->CI->db)) + { + $query = $this->CI->db->limit(1)->get_where($table, array($field => $str)); + return $query->num_rows() === 0; + } + return FALSE; } // -------------------------------------------------------------------- |