CodeIgniter Forums
Unknown column 'Array' - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Unknown column 'Array' (/showthread.php?tid=70697)



Unknown column 'Array' - davy_yg - 05-16-2018

Hello,

I wonder why I get this error message? I thought I already define the array.

Error Number: 1054
Unknown column 'Array' in 'where clause'
SELECT `id` FROM `users` WHERE `referral_code` = Array
Filename: C:/xampp/htdocs/iPengen_Marketing_new/api/system/database/DB_driver.php
Line Number: 691



users_model.php

     function FindUserIdChild($data = array())
        {
        // referral code bkn marketing leader
        $this->db->select('id');
        $this->db->where('referral_code', $data);
        $this->db->from($this->table);
        return $this->db->get()->result();

        }

controllers/marketing.php
       
        $ref_code = 'ABC15';

        $dna['dna'] = $this->users_model->FindDnaCodeChild($ref_code);
        
        $users2 = $this->users_model->FindUserIdChild($dna);


RE: Unknown column 'Array' - qury - 05-17-2018

Hi,

According to the documentation where() takes either an associative array as input or you have to call specify the field and value to look for.

PHP Code:
$dataArray=[
 
 'referral_code'=>'ABC15',
];
$this->db->where($dataArray);
// OR
$this->db->where('referral_code','ABC15'

Check here: https://www.codeigniter.com/user_guide/database/query_builder.html#looking-for-specific-data