summaryrefslogtreecommitdiffstats
path: root/system/database/DB_active_rec.php
diff options
context:
space:
mode:
authorDerek Allard <derek.allard@ellislab.com>2007-12-19 16:53:44 +0100
committerDerek Allard <derek.allard@ellislab.com>2007-12-19 16:53:44 +0100
commite54e3d2786b76266e6b6dde481cc493ba002faae (patch)
tree62471aa33e133246bfd85a029851a448b57ebe8c /system/database/DB_active_rec.php
parente77d77c6b4c094483a3d85b23845436b77796d07 (diff)
where_in_or became or_where_in(), where_not_in_or() became or_where_not_in() for consistency
Added not_like() and or_not_like()
Diffstat (limited to 'system/database/DB_active_rec.php')
-rw-r--r--system/database/DB_active_rec.php57
1 files changed, 47 insertions, 10 deletions
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index cea9bddc5..0a4327b42 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -276,7 +276,7 @@ class CI_DB_active_record extends CI_DB_driver {
* @return object
*/
- function where_in_or($key = NULL, $values = NULL)
+ function or_where_in($key = NULL, $values = NULL)
{
return $this->_where_in($key, $values, FALSE, 'or');
}
@@ -314,7 +314,7 @@ class CI_DB_active_record extends CI_DB_driver {
* @return object
*/
- function where_not_in_or($key = NULL, $values = NULL)
+ function or_where_not_in($key = NULL, $values = NULL)
{
return $this->_where_in($key, $values, FALSE, 'or');
}
@@ -372,7 +372,25 @@ class CI_DB_active_record extends CI_DB_driver {
{
return $this->_like($field, $match, 'AND ', $side);
}
-
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Not Like
+ *
+ * Generates a NOT LIKE portion of the query. Separates
+ * multiple calls with AND
+ *
+ * @access public
+ * @param mixed
+ * @param mixed
+ * @return object
+ */
+ function not_like($field, $match = '', $side = 'both')
+ {
+ return $this->_like($field, $match, 'AND ', $side, ' NOT');
+ }
+
// --------------------------------------------------------------------
/**
@@ -394,6 +412,24 @@ class CI_DB_active_record extends CI_DB_driver {
// --------------------------------------------------------------------
/**
+ * OR Not Like
+ *
+ * Generates a NOT LIKE portion of the query. Separates
+ * multiple calls with OR
+ *
+ * @access public
+ * @param mixed
+ * @param mixed
+ * @return object
+ */
+ function or_not_like($field, $match = '', $side = 'both')
+ {
+ return $this->_like($field, $match, 'OR ', $side, 'NOT ');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* orlike() is an alias of or_like()
* this function is here for backwards compatibility, as
* orlike() has been deprecated
@@ -416,7 +452,7 @@ class CI_DB_active_record extends CI_DB_driver {
* @param string
* @return object
*/
- function _like($field, $match = '', $type = 'AND ', $side = 'both')
+ function _like($field, $match = '', $type = 'AND ', $side = 'both', $not = '')
{
if ( ! is_array($field))
{
@@ -424,22 +460,23 @@ class CI_DB_active_record extends CI_DB_driver {
}
foreach ($field as $k => $v)
- {
+ {
+
$prefix = (count($this->ar_like) == 0) ? '' : $type;
-
+
$v = $this->escape_str($v);
-
+
if ($side == 'before')
{
- $this->ar_like[] = $prefix." $k LIKE '%{$v}'";
+ $this->ar_like[] = $prefix." $k $not LIKE '%{$v}'";
}
elseif ($side == 'after')
{
- $this->ar_like[] = $prefix." $k LIKE '{$v}%'";
+ $this->ar_like[] = $prefix." $k $not LIKE '{$v}%'";
}
else
{
- $this->ar_like[] = $prefix." $k LIKE '%{$v}%'";
+ $this->ar_like[] = $prefix." $k $not LIKE '%{$v}%'";
}
}
return $this;