-1

Hi guys I am trying to select all the users in my database with an array of USER ID. I am coding in PHP and this is my code so far but I get an error saying I am trying to use an array.

$relative = $this->db->select('user_id, fname, surname')->get_where('user_view_view', array('user_id'=>$mytest))->result_array();

My array of user ids is called:

$mytest

What am I doing wrong?

  • Possible duplicate of [PHP - Using PDO with IN clause array](http://stackoverflow.com/questions/14767530/php-using-pdo-with-in-clause-array) – Mikel Bitson Nov 20 '15 at 13:55

1 Answers1

1

try something like that

$query = $this->db
    ->select('user_id, fname, surname')
    ->from("user_view_view")
    ->where_in("user_id",$myTest)
    ->get();

$relative = $query->result_array();

the reason why it won't work is because get_where doesn't accept an array as field_value

you should get an error with the message "Array to string conversion"

Atural
  • 5,389
  • 5
  • 18
  • 35