Welcome Guest, Not a member yet? Register   Sign In
'OR Like' MySQL - Maybe a bug?
#2

[eluser]N3XT0R[/eluser]
I got a solution, maybe not the best, but currently i think is every solution better:

CI_DB_active_record Class changes:
Code:
//Declaring and initialization of $ar_or_like
after Line 35 added.
var $ar_or_like                         = array();

//Adding array to the Reset-Function for Select.
after line 2032 added (Reset-Funktion):
'ar_or_like'                    => array(), // Zeile eingefügt.

//Adding array to the Reset-Function for write.
after line 2002 added:
'ar_or_like'                    => array(), // Zeile eingefügt.


after line  617 added:
array_push($this->ar_or_like, array($field, $match));

/**
* Check if or_like is set and replace the first "AND" (which will be everytime set
* when more than 0 like are setted too) with "OR", when ar_or_like is higher than 0.
*/
Line 1746 -  1754 replaced with:
if (count($this->ar_like) > 0 && count($this->ar_or_like) == 0)
{
if (count($this->ar_where) > 0)
{
  $sql .= "\nAND ";
}elseif(count($this->ar_or_like) > 0){
  $sql .= "\nOR ";
}

$sql .= implode("\n", $this->ar_like);
}
Notice:
Only done changes for select, this solution is not working for replace into or anything else.
Maybe it is helpful for another person, too.


Messages In This Thread
'OR Like' MySQL - Maybe a bug? - by El Forum - 06-27-2013, 07:22 AM
'OR Like' MySQL - Maybe a bug? - by El Forum - 06-28-2013, 01:09 AM
'OR Like' MySQL - Maybe a bug? - by El Forum - 06-28-2013, 08:07 AM
'OR Like' MySQL - Maybe a bug? - by El Forum - 06-28-2013, 09:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB