Welcome Guest, Not a member yet? Register   Sign In
ActiveRecord like_in
#1

[eluser]maf_9000[/eluser]
i want to search in db with an array
Code:
$this->db->where_in('tags', $tags);
is giving me the exact result not matching
and
Code:
$this->db->like('tags', $tags);
doesn't take arrays (or it dose ?)

any help please
#2

[eluser]InsiteFX[/eluser]
where_in does not take an array!

But you could use like which does take an Associative array.

InsiteFX
#3

[eluser]maf_9000[/eluser]
thanks Mr InsiteFX
i need to search in tags column in db with any element of the array $tags i have created
what is the syntax please
#4

[eluser]danmontgomery[/eluser]
[quote author="InsiteFX" date="1301595456"]where_in does not take an array!

But you could use like which does take an Associative array.

InsiteFX[/quote]

where_in only takes arrays...

Code:
$this->db->where_in('some_field', array(1,2,3,4));


[quote author="maf_9000" date="1301596961"]thanks Mr InsiteFX
i need to search in tags column in db with any element of the array $tags i have created
what is the syntax please[/quote]

There's no "like in" functionality in MySQL, you would have to use or_like, or manually construct a where() string.

Code:
$this->db->or_like('field', 'value_a');
$this->db->or_like('field', 'value_b');

// or

$this->db->where('(`field` LIKE "%value_a%" OR `field` LIKE "%value_b%")', NULL, FALSE);
#5

[eluser]InsiteFX[/eluser]
@noctrum, Thanks I must have read it wrong! Plus I think I am spending to much time on here LOL!

InsiteFX
#6

[eluser]maf_9000[/eluser]
thanks noctrum
i have used the following code
Code:
foreach ($tags as $tag){
            $this->db->or_like('tags', urldecode($tag));
        }




Theme © iAndrew 2016 - Forum software by © MyBB